@@ -47,6 +47,32 @@ package camelCase
import "fmt"
// ChangeMe
+t4018 description: import (
+t4018 header: import (
+package somePackage
+
+import (
+ "os"
+ ChangeMe
+)
+
+t4018 description: const (
+t4018 header: const (
+package somePackage
+
+const (
+ Foo = 1
+ Bar = ChangeMe
+)
+
+t4018 description: const rule is selective
+t4018 header: package main
+package main
+
+const Foo = "Bar"
+
+// ChangeMe
+
t4018 description: complex function
t4018 header: func (t *Test) RIGHT(a Type) (Type, error) {
type Test struct {
@@ -132,6 +132,8 @@ PATTERNS("golang",
"^(package[ \t][a-z][A-Za-z0-9_]+)[ \t]*\n"
/* Functions */
"^(func[ \t].*)\n"
+ /* const & import */
+ "^((import|const)[ \t]*\\([ \t]*)\n"
/* Structs and interfaces */
"^(type[ \t].*[ \t](struct|interface)[ \t].*)",
/* -- */
Add matching rules for the very common pattern of having a multi-line "import" or "const" declaration near the start of the "package" line. Before this change we'd skip this and match whatever came before it, e.g. the "package" line. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- t/t4018/golang | 26 ++++++++++++++++++++++++++ userdiff.c | 2 ++ 2 files changed, 28 insertions(+)