Skip to content

Commit 85ee97f

Browse files
committed
support config and fix issues in self project
1 parent 051922e commit 85ee97f

File tree

192 files changed

+52992
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+52992
-275
lines changed

.golangci.example.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
run:
2+
args:
3+
- ./...
4+
verbose: true
5+
concurrency: 4
6+
deadline: 1m
7+
issues-exit-code: 1
8+
tests: true
9+
build-tags:
10+
- mytag
11+
12+
output:
13+
format: colored-line-number
14+
print-issued-lines: true
15+
print-linter-name: true
16+
print-welcome: true
17+
18+
linters-settings:
19+
errcheck:
20+
check-type-assertions: false
21+
check-blank: false
22+
govet:
23+
check-shadowing: true
24+
golint:
25+
min-confidence: 0.8
26+
gofmt:
27+
simplify: true
28+
gocyclo:
29+
min-complexity: 10
30+
maligned:
31+
suggest-new: true
32+
dupl:
33+
threshold: 50
34+
goconst:
35+
min-len: 3
36+
min-occurrences: 3
37+
38+
linters:
39+
enable:
40+
- megacheck
41+
- vet
42+
enable-all: true
43+
disable:
44+
maligned
45+
disable-all: false
46+
presets:
47+
- bugs
48+
- unused
49+
50+
issues:
51+
exclude:
52+
- abcdef
53+
exclude-use-default: true
54+
max-per-linter: 0
55+
max-same: 0
56+
new: false
57+
new-from-rev: ""
58+
new-from-patch: ""

.golangci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
run:
2+
verbose: true
3+
deadline: 30s
4+
tests: true
5+
6+
linters-settings:
7+
errcheck:
8+
check-type-assertions: true
9+
check-blank: true
10+
govet:
11+
check-shadowing: true
12+
golint:
13+
min-confidence: 0
14+
gocyclo:
15+
min-complexity: 10
16+
maligned:
17+
suggest-new: true
18+
dupl:
19+
threshold: 100
20+
goconst:
21+
min-len: 2
22+
min-occurrences: 2
23+
24+
linters:
25+
enable-all: true
26+
disable:
27+
- maligned
28+
29+
issues:
30+
exclude:
31+
- should have a package comment

Gopkg.lock

Lines changed: 77 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@
6969
[prune]
7070
go-tests = true
7171
unused-packages = true
72+
73+
[[constraint]]
74+
name = "github.com/spf13/viper"
75+
version = "1.0.2"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
test:
2+
golangci-lint run
23
go test -v -race ./...

internal/commands/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Executor struct {
1515

1616
func NewExecutor() *Executor {
1717
e := &Executor{
18-
cfg: config.NewDefault(),
18+
cfg: &config.Config{},
1919
}
2020

2121
e.initRoot()

internal/commands/root.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ func (e *Executor) initRoot() {
1616
Short: "golangci-lint is a smart linters runner.",
1717
Long: `Smart, fast linters runner. Run it in cloud for every GitHub pull request on https://golangci.com`,
1818
Run: func(cmd *cobra.Command, args []string) {
19-
_ = cmd.Help()
19+
if err := cmd.Help(); err != nil {
20+
log.Fatal(err)
21+
}
2022
},
2123
PersistentPreRun: func(cmd *cobra.Command, args []string) {
22-
runtime.GOMAXPROCS(e.cfg.Common.Concurrency)
24+
runtime.GOMAXPROCS(e.cfg.Run.Concurrency)
2325

24-
if e.cfg.Common.IsVerbose {
26+
if e.cfg.Run.IsVerbose {
2527
logrus.SetLevel(logrus.InfoLevel)
2628
}
2729

28-
if e.cfg.Common.CPUProfilePath != "" {
29-
f, err := os.Create(e.cfg.Common.CPUProfilePath)
30+
if e.cfg.Run.CPUProfilePath != "" {
31+
f, err := os.Create(e.cfg.Run.CPUProfilePath)
3032
if err != nil {
3133
log.Fatal(err)
3234
}
@@ -36,14 +38,15 @@ func (e *Executor) initRoot() {
3638
}
3739
},
3840
PersistentPostRun: func(cmd *cobra.Command, args []string) {
39-
if e.cfg.Common.CPUProfilePath != "" {
41+
if e.cfg.Run.CPUProfilePath != "" {
4042
pprof.StopCPUProfile()
4143
}
4244
os.Exit(e.exitCode)
4345
},
4446
}
45-
rootCmd.PersistentFlags().BoolVarP(&e.cfg.Common.IsVerbose, "verbose", "v", false, "verbose output")
46-
rootCmd.PersistentFlags().StringVar(&e.cfg.Common.CPUProfilePath, "cpu-profile-path", "", "Path to CPU profile output file")
47-
rootCmd.PersistentFlags().IntVarP(&e.cfg.Common.Concurrency, "concurrency", "j", runtime.NumCPU(), "Concurrency")
47+
rootCmd.PersistentFlags().BoolVarP(&e.cfg.Run.IsVerbose, "verbose", "v", false, "verbose output")
48+
rootCmd.PersistentFlags().StringVar(&e.cfg.Run.CPUProfilePath, "cpu-profile-path", "", "Path to CPU profile output file")
49+
rootCmd.PersistentFlags().IntVarP(&e.cfg.Run.Concurrency, "concurrency", "j", runtime.NumCPU(), "Concurrency")
50+
4851
e.rootCmd = rootCmd
4952
}

0 commit comments

Comments
 (0)