Skip to content

Commit 9522ee1

Browse files
author
Denis Krivak
committed
Add linter checks.
1 parent 7c2e17b commit 9522ee1

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

.golangci.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
run:
2+
concurrency: 2
3+
deadline: 5m
4+
5+
skip-dirs:
6+
- path: ./testdata/
7+
8+
linters:
9+
disable-all: true
10+
enable:
11+
- deadcode
12+
- errcheck
13+
- gosimple
14+
- govet
15+
- ineffassign
16+
- staticcheck
17+
- structcheck
18+
- typecheck
19+
- unused
20+
- varcheck
21+
- bodyclose
22+
- depguard
23+
- dogsled
24+
- dupl
25+
- funlen
26+
- gochecknoinits
27+
- goconst
28+
- gocritic
29+
- gocyclo
30+
- godot
31+
- gofmt
32+
- goimports
33+
- golint
34+
- gomnd
35+
- gomodguard
36+
- goprintffuncname
37+
- gosec
38+
- lll
39+
- maligned
40+
- misspell
41+
- nakedret
42+
- nestif
43+
- prealloc
44+
- rowserrcheck
45+
- scopelint
46+
- stylecheck
47+
- unconvert
48+
- unparam
49+
- whitespace
50+
51+
issues:
52+
exclude-use-default: false
53+
exclude-rules:
54+
- path: _test\.go
55+
linters:
56+
- funlen
57+
- path: cmd/godot/main\.go
58+
linters:
59+
- gomnd

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
test:
33
go test ./...
44

5+
.PHONY: lint
6+
lint:
7+
@ golangci-lint run
8+
59
.PHONY: build
610
build:
711
go build -o godot ./cmd/godot

cmd/godot/main.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Options:
2424

2525
func main() {
2626
if len(os.Args) < 2 {
27-
fatal(usage)
27+
fatalf(usage)
2828
}
2929
if os.Args[1] == "-h" || os.Args[1] == "--help" {
3030
fmt.Println(usage)
@@ -35,14 +35,14 @@ func main() {
3535
os.Exit(0)
3636
}
3737
if strings.HasPrefix(os.Args[1], "-") && os.Args[1] != "-a" && os.Args[1] == "--all" {
38-
fatal("Unknown flag")
38+
fatalf("Unknown flag")
3939
}
4040

4141
var settings godot.Settings
4242
input := os.Args[1:]
4343
if os.Args[1] == "-a" || os.Args[1] == "--all" {
4444
if len(os.Args) < 3 {
45-
fatal(usage)
45+
fatalf(usage)
4646
}
4747
settings.CheckAll = true
4848
input = os.Args[2:]
@@ -53,12 +53,12 @@ func main() {
5353

5454
for _, path := range input {
5555
if _, err := os.Stat(path); os.IsNotExist(err) {
56-
fatal("Path %s does not exist", path)
56+
fatalf("Path %s does not exist", path)
5757
}
5858
for f := range findFiles(path) {
5959
file, err := parser.ParseFile(fset, f, nil, parser.ParseComments)
6060
if err != nil {
61-
fatal("Failed to parse file %s: %v", path, err)
61+
fatalf("Failed to parse file %s: %v", path, err)
6262
}
6363
files = append(files, file)
6464
}
@@ -88,14 +88,14 @@ func findFiles(root string) chan string {
8888
return nil
8989
})
9090
if err != nil {
91-
fatal("Failed to get files from directory: %v", err)
91+
fatalf("Failed to get files from directory: %v", err)
9292
}
9393
}()
9494

9595
return out
9696
}
9797

98-
func fatal(format string, args ...interface{}) {
98+
func fatalf(format string, args ...interface{}) {
9999
fmt.Printf(format+"\n", args...)
100100
os.Exit(1)
101101
}

0 commit comments

Comments
 (0)