diff --git a/pkg/moq/moq.go b/pkg/moq/moq.go index f4b43c0..ae37714 100644 --- a/pkg/moq/moq.go +++ b/pkg/moq/moq.go @@ -15,6 +15,49 @@ import ( "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. type Mocker struct { src string @@ -240,6 +283,11 @@ var templateFuncs = template.FuncMap{ if s == "" { return "" } + for _, initialism := range golintInitialisms { + if strings.ToUpper(s) == initialism { + return initialism + } + } return strings.ToUpper(s[0:1]) + s[1:] }, } diff --git a/pkg/moq/moq_test.go b/pkg/moq/moq_test.go index 4cd6fc9..bfa7fe1 100644 --- a/pkg/moq/moq_test.go +++ b/pkg/moq/moq_test.go @@ -31,6 +31,7 @@ func TestMoq(t *testing.T) { "lockPersonStoreMockGet.Lock()", "mock.calls.Get = append(mock.calls.Get, callInfo)", "lockPersonStoreMockGet.Unlock()", + "// ID is the id argument value", } for _, str := range strs { if !strings.Contains(s, str) {