MySQL配置文件my.cnf详解

使用ClickHouse的MaterializeMySQL,将mysql某个库或某张表导入到ck中,需要保证MySQL的配置大致如下:

1
2
3
4
5
6
default_authentication_plugin = mysql_native_password
gtid_mode = ON
enforce_gtid_consistency = ON
#log_bin = /data/mysql/log_binry.log
server_id = 1
log_bin = ON

可以 SHOW VARIABLES LIKE 'default_authentication_plugin';查看默认值

Go interface{}转struct

写一个通用的方法,更具type字段区分不同类型,入参不同,返回值也不同

POST方式,type=8带在路径中,其他业务相关的参数放在body里

如果用gin框架,可以用c.GetQuery(key)获取type类型

Unix后记&寻找Shen Lin


看『左耳朵耗子』这篇UNIX 50 年:KEN THOMPSON 的密码,意外获知KEN,DMR,RMS之外,能够拥有三位字母简称,且在极客圈中得到广泛认可的另一位大神——BWK。同样是贝尔实验室出来的研究员,当初跟着K&R开发unix。另外,awk中的“k”,那本C语言经典<C程序设计语言>作者K&R中的“k”,均指此人 --- 所以,K&R在分指Unix和C时,“K”竟然有不同涵义…

runtime.Caller的性能问题

前置篇 golang获取调用者的方法名及所在行数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Caller reports file and line number information about function invocations on
// the calling goroutine's stack. The argument skip is the number of stack frames
// to ascend, with 0 identifying the caller of Caller. (For historical reasons the
// meaning of skip differs between Caller and Callers.) The return values report the
// program counter, file name, and line number within the file of the corresponding
// call. The boolean ok is false if it was not possible to recover the information.
func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
rpc := make([]uintptr, 1)
n := callers(skip+1, rpc[:])
if n < 1 {
return
}
frame, _ := CallersFrames(rpc).Next()
return frame.PC, frame.File, frame.Line, frame.PC != 0
}
Caller报告有关函数调用的文件和行号信息 调用 goroutine 的堆栈。 参数 skip 是堆栈帧的数量 上升,0 标识呼叫者的caller。 (由于历史原因 跳过的含义在调用者和调用者之间有所不同。)返回值报告 相应的文件中的程序计数器、文件名和行号 称呼。 如果无法恢复信息,则布尔值 ok 为 false。

Google Authenticator实现原理

曾就职的公司好几家都使用谷歌认证器(Google Authenticator,俗称谷歌令牌),作为二次校验的工具.相比于短信这样的并不算安全的OTP(One Time Password),使用令牌可以增强安全性, 同时还节省了短信的费用.

类似产品还有阿里巴巴的身份宝,默认的时间是60秒; 腾讯的Token,时间是60秒

SOLID原则

SOLID原则指五个面向对象的设计原则,每个设计原则的首字母拼起来,刚好是SOLID这个单词:

SRP: 单一职责原则。每个软件模块有且只有一个需要被改变的理由。

OCP: 开闭原则。软件系统应该允许通过新增代码来修改原有系统行为,而不是通过修改现有代码。

Routine-Tech


代码调试

使用go module且生成vendor,想要(临时)修改用到的第三方包的代码,go run/go build时改动的代码是无效的..

当确实需要修改第三方的包,这个问题该怎样较好解决的?