Add go-header linter ()

* add go-header linter
* apply review comments: add goheader example into .golangci.example.yml
* apply review comments: correctly handle multiline comments
This commit is contained in:
Denis Tingaikin 2020-07-05 02:03:37 +07:00 committed by GitHub
parent b22e3f1874
commit 01b566a646
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 139 additions and 1 deletions

View file

@ -173,6 +173,12 @@ func buildConfigFromShortRepr(t *testing.T, repr string, config map[string]inter
lastObj[keyParts[len(keyParts)-1]] = kv[1]
}
func skipMultilineComment(scanner *bufio.Scanner) {
for line := scanner.Text(); !strings.Contains(line, "*/") && scanner.Scan(); {
line = scanner.Text()
}
}
func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext {
f, err := os.Open(sourcePath)
assert.NoError(t, err)
@ -183,10 +189,13 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "/*") {
skipMultilineComment(scanner)
continue
}
if !strings.HasPrefix(line, "//") {
return rc
}
line = strings.TrimPrefix(line, "//")
if strings.HasPrefix(line, "args: ") {
assert.Nil(t, rc.args)