base64 及 base64 url-safe

背景 在一次开发中,服务端需要接受某个参数为 base64 编码的值,测试所得服务端所得的编码值无法与前端所传的值匹配不上,即所传的参数不是服务端所需的正确的编码值。后联调得知,服务端需要接收的是 base64 url-safe 的值,所以前端需要也对数据进行 base64 编码为 url-safe 的值。 遇到问题的相关 issue: https://github.com/brix/crypto-js/issues/252 问题复现 1 2 3 4 5 // 有效的 base64 字符如下: // ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop
阅读更多

Go语言中占位符的使用

原文地址: https://studygolang.com/articles/21039 定义示例类型和变量 1 2 3 4 type Human struct { Name string } var people = Human{Name:"zhangsan"} 1. 普通占位符 占位符说明举例输出%v相应值的默认格式。Printf(“%v”, people){zhangsan}%+v打印结构体时,会添加字段名Printf(“%+v”, people){Name:zhangsan}%#v相应值的Go语法表示Printf(“#v”, people)main.Human{Name:”
阅读更多

go test报错 wrong signature for TestAdd, must be: func TestAdd(t *testing.T)

参考: https://www.cnblogs.com/mingbai/p/gotesterr.html 背景 学习 Go 过程中,在终端输入 go test 显示报错: 1 $ wrong signature for TestAdd, must be: func TestAdd(t *testing.T) 后经搜索该报错查明示由于 func TestAdd(t testing.T) 参数未带 *,需要改为 func TestAdd(t *testing.T) 问题复现 报错代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
阅读更多