Ensure generated content is friendlier to golint
I've stolen the list of "initialisms" from the golint codebase. Normally I might try and figure out some way to bring the list in from the source rather than just copy and paste it, since it may fall out of date in the future. However, if you've ever followed any of the PRs in the golint repository, you'll know any change like that would likely be rejected. Most of this list hasn't changed in the last 4 years, so my feeling is that it won't require many more updates for the life of this project.
This commit is contained in:
parent
cc6b1a47fa
commit
b2769851ce
@ -15,6 +15,49 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This list comes from the golint codebase. Golint will complain about any of
|
||||||
|
// these being mixed-case, like "Id" instead of "ID".
|
||||||
|
var golintInitialisms = []string{
|
||||||
|
"ACL",
|
||||||
|
"API",
|
||||||
|
"ASCII",
|
||||||
|
"CPU",
|
||||||
|
"CSS",
|
||||||
|
"DNS",
|
||||||
|
"EOF",
|
||||||
|
"GUID",
|
||||||
|
"HTML",
|
||||||
|
"HTTP",
|
||||||
|
"HTTPS",
|
||||||
|
"ID",
|
||||||
|
"IP",
|
||||||
|
"JSON",
|
||||||
|
"LHS",
|
||||||
|
"QPS",
|
||||||
|
"RAM",
|
||||||
|
"RHS",
|
||||||
|
"RPC",
|
||||||
|
"SLA",
|
||||||
|
"SMTP",
|
||||||
|
"SQL",
|
||||||
|
"SSH",
|
||||||
|
"TCP",
|
||||||
|
"TLS",
|
||||||
|
"TTL",
|
||||||
|
"UDP",
|
||||||
|
"UI",
|
||||||
|
"UID",
|
||||||
|
"UUID",
|
||||||
|
"URI",
|
||||||
|
"URL",
|
||||||
|
"UTF8",
|
||||||
|
"VM",
|
||||||
|
"XML",
|
||||||
|
"XMPP",
|
||||||
|
"XSRF",
|
||||||
|
"XSS",
|
||||||
|
}
|
||||||
|
|
||||||
// Mocker can generate mock structs.
|
// Mocker can generate mock structs.
|
||||||
type Mocker struct {
|
type Mocker struct {
|
||||||
src string
|
src string
|
||||||
@ -240,6 +283,11 @@ var templateFuncs = template.FuncMap{
|
|||||||
if s == "" {
|
if s == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
for _, initialism := range golintInitialisms {
|
||||||
|
if strings.ToUpper(s) == initialism {
|
||||||
|
return initialism
|
||||||
|
}
|
||||||
|
}
|
||||||
return strings.ToUpper(s[0:1]) + s[1:]
|
return strings.ToUpper(s[0:1]) + s[1:]
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ func TestMoq(t *testing.T) {
|
|||||||
"lockPersonStoreMockGet.Lock()",
|
"lockPersonStoreMockGet.Lock()",
|
||||||
"mock.calls.Get = append(mock.calls.Get, callInfo)",
|
"mock.calls.Get = append(mock.calls.Get, callInfo)",
|
||||||
"lockPersonStoreMockGet.Unlock()",
|
"lockPersonStoreMockGet.Unlock()",
|
||||||
|
"// ID is the id argument value",
|
||||||
}
|
}
|
||||||
for _, str := range strs {
|
for _, str := range strs {
|
||||||
if !strings.Contains(s, str) {
|
if !strings.Contains(s, str) {
|
||||||
|
Loading…
Reference in New Issue
Block a user