在Go语言中,是否有可能覆盖自动格式化器?

huangapple go评论88阅读模式
英文:

is it possible to override the automatic formatter in go

问题

在一个GO结构体中,我个人不喜欢按照约定将id字段命名为UserID。有没有办法告诉GO格式化程序,UserId是可以接受的,不要再给我警告了?

英文:

In a GO struct I personally do not like the id fields following the convension - UserID. Is there a way to tell the GO formatter that UserId is ok and to stop giving me a warning?

答案1

得分: 6

只需fork golint 仓库并根据您的喜好修改 lintNames 函数即可:https://github.com/golang/lint/blob/32a87160691b3c96046c0c678fe57c5bef761456/lint.go#L510

我的建议是:不要覆盖惯例,否则您的代码将对其他Gopher来说显得陌生!

英文:

Just fork the golint repo and modify the lintNames function as you like: https://github.com/golang/lint/blob/32a87160691b3c96046c0c678fe57c5bef761456/lint.go#L510

My suggestion: Don't override conventions or your code will look alien to other Gophers!

huangapple
  • 本文由 发表于 2015年12月14日 23:51:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/34271248.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定