Allow one underscore between digits.
Fixes #47
Signed-off-by: David Symonds <dsymonds@golang.org>
diff --git a/lint.go b/lint.go
index af7e2e6..8dbe3ea 100644
--- a/lint.go
+++ b/lint.go
@@ -614,6 +614,12 @@
for i+n+1 < len(runes) && runes[i+n+1] == '_' {
n++
}
+
+ // Leave at most one underscore if the underscore is between two digits
+ if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) {
+ n--
+ }
+
copy(runes[i+1:], runes[i+n+1:])
runes = runes[:len(runes)-n]
} else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) {
diff --git a/lint_test.go b/lint_test.go
index f0a0acc..c169af2 100644
--- a/lint_test.go
+++ b/lint_test.go
@@ -190,6 +190,10 @@
{"a__b", "aB"},
{"a___b", "aB"},
{"Rpc1150", "RPC1150"},
+ {"case3_1", "case3_1"},
+ {"case3__1", "case3_1"},
+ {"IEEE802_16bit", "IEEE802_16bit"},
+ {"IEEE802_16Bit", "IEEE802_16Bit"},
}
for _, test := range tests {
got := lintName(test.name)
diff --git a/testdata/names.go b/testdata/names.go
index 9b2bf17..4e84597 100644
--- a/testdata/names.go
+++ b/testdata/names.go
@@ -71,3 +71,17 @@
F(foo_bar int) // MATCH /foo_bar.*fooBar/
}
+
+// All okay; underscore between digits
+const case1_1 = 1
+
+type case2_1 struct {
+ case2_2 int
+}
+
+func case3_1(case3_2 int) (case3_3 string) {
+ case3_4 := 4
+ _ = case3_4
+
+ return ""
+}