Explicitly whitelist LastInsertId and kWh as exempt from the naming checks.
diff --git a/lint.go b/lint.go
index e84f46d..6315eba 100644
--- a/lint.go
+++ b/lint.go
@@ -522,6 +522,14 @@
var allCapsRE = regexp.MustCompile(`^[A-Z0-9_]+$`)
+// knownNameExceptions is a set of names that are known to be exempt from naming checks.
+// This is usually because they are constrained by having to match names in the
+// standard library.
+var knownNameExceptions = map[string]bool{
+ "LastInsertId": true, // must match database/sql
+ "kWh": true,
+}
+
// lintNames examines all names in the file.
// It complains if any use underscores or incorrect known initialisms.
func (f *file) lintNames() {
@@ -534,6 +542,9 @@
if id.Name == "_" {
return
}
+ if knownNameExceptions[id.Name] {
+ return
+ }
// Handle two common styles from other languages that don't belong in Go.
if len(id.Name) >= 5 && allCapsRE.MatchString(id.Name) && strings.Contains(id.Name, "_") {
diff --git a/testdata/names.go b/testdata/names.go
index 4e84597..f884fab 100644
--- a/testdata/names.go
+++ b/testdata/names.go
@@ -85,3 +85,7 @@
return ""
}
+
+type t struct{}
+
+func (t) LastInsertId() (int64, error) { return 0, nil } // okay because it matches a known style violation