ecapture icon indicating copy to clipboard operation
ecapture copied to clipboard

style: unified space

Open xxxxxliil opened this issue 1 year ago • 7 comments

调整了一些输出的空格风格,例如把 str:{f}str :{f}str : {f} 改为 str: {f}。 剪裁没必要的空格,例如部分字符串中间不规律的双重空格、尾部的空格

发现但未在此次 commit 更改,需要讨论的:

pkg/proc/proc_test.go#L40 建议 : 换成 = pkg/event_processor/base_event.go#L150-166 + user/config/mysqld.go#L107 两个半型冒号 user/envent/event_gnutls.go#L81-97 TIDType 位置对调且 String() 函数中 TYPE 全大写 user/envent/event_mastersec_gotls.go#L75 Label 似乎缺少半型冒号 user/envent/event_nspr.go#L85 Payload 输出似乎缺少换行 user/envent/event_openssl.go#L153-175 StringStringHex 日志输出 Send/RecvVersion 位置对调

xxxxxliil avatar Aug 26 '24 04:08 xxxxxliil

建议你增加一些这类问题的防范、检测方法,不只是这一次的修复问题。

比如 make format 去直接format,以及 Github Action 增加检测。

cfc4n avatar Aug 26 '24 04:08 cfc4n

建议你增加一些这类问题的防范、检测方法,不只是这一次的修复问题。

比如 make format 去直接format,以及 Github Action 增加检测。

我也想,但不会😞。手工加正则看字符串的时候发现有一些直接全部替换的话,不是部分匹配不到就是直接改得更糟

xxxxxliil avatar Aug 26 '24 06:08 xxxxxliil

看下clang-format是否支持呢?另外,google的编码规范是否采用了你这种标准?

cfc4n avatar Aug 26 '24 14:08 cfc4n

另外,google的编码规范是否采用了你这种标准?

google 编码规范完全没有讲字符串内格式化字符应该怎么放,但是多种样式齐聚一堂也不是好做法 如果非要从编码规范找的话,示例里是有一段 https://google.github.io/styleguide/go/guide#maintainability

xxxxxliil avatar Aug 27 '24 08:08 xxxxxliil

从代码规范上来看,我支持你的这个提议。不过,我期望是形成一套机制,不能只是本次对历史代码的修正,而是对未来新增代码做卡控。 这种机制,最好增加到自动化格式指令中(make format),卡控手段增加到Github Action中。

希望可以往这个方向上尝试, 感谢。

cfc4n avatar Aug 29 '24 05:08 cfc4n

我会在之后尝试的,但是因为一些原因在最近一段时间是没有时间了

xxxxxliil avatar Aug 29 '24 10:08 xxxxxliil

目前仍未找到合适的工具进行字符串格式化……转为 draft

xxxxxliil avatar Sep 10 '24 14:09 xxxxxliil