![]() | 1 bv 16 天前 ![]() type Password string func (p Password) MarshalText() ([]byte, error) { return []byte("******"), nil } type User struct { Name string `json:"name"` Password Password `json:"password"` } u := &User{Name: "Alice", Password: "abc123456"} json.NewEncoder(os.Stdout).Encode(u) // output: {"name":"Alice","password":"******"} |
![]() | 2 MHPSY 16 天前 字段很多吗,应该就自己加入几个相关的规则,套就好,规则应该不会很难穷举完 |
3 ohohohh OP ok ,感谢各位大佬 |
![]() | 4 masterclock 16 天前 我们在稍上层做,用 OPA 这样的东西过滤 |
5 baerwang 16 天前 @masterclock opa 性能如何? |
![]() | 6 Desdemor 16 天前 @masterclock 中间件里面? |
![]() | 7 kuanat 16 天前 ![]() https://pkg.go.dev/log/slog@master#example-LogValuer-Secret 这是 golang slog 官方示例写法,和一楼给的思路是一样的。需要通用性做成接口就好了。 |
![]() | 8 bronyakaka 16 天前 弄个正则集,密码之类的网上都有。输出的时候匹配下就行了 |
![]() | 9 czyt 16 天前 ![]() |