File tree Expand file tree Collapse file tree 10 files changed +229
-16
lines changed Expand file tree Collapse file tree 10 files changed +229
-16
lines changed Original file line number Diff line number Diff line change 1+ name : golangci-lint
2+ on :
3+ push :
4+ branches :
5+ - main
6+ - master
7+ pull_request :
8+
9+ permissions :
10+ contents : read
11+
12+ env :
13+ GOLANGCI_LINT_VERSION : v1.60
14+ CGO_ENABLED : 0
15+
16+ jobs :
17+ golangci :
18+ strategy :
19+ matrix :
20+ go : [stable]
21+ os : [ubuntu-latest, macos-latest, windows-latest]
22+ name : lint
23+ runs-on : ${{ matrix.os }}
24+ steps :
25+ - uses : actions/checkout@v4
26+ - uses : actions/setup-go@v5
27+ with :
28+ go-version : ${{ matrix.go }}
29+
30+ - name : Check and get dependencies
31+ run : |
32+ go mod download
33+ go mod tidy
34+ git diff --exit-code go.mod
35+ git diff --exit-code go.sum
36+
37+ - name : golangci-lint
38+ uses : golangci/golangci-lint-action@v6
39+ with :
40+ version : ${{ env.GOLANGCI_LINT_VERSION }}
Original file line number Diff line number Diff line change 1+ name : Tests
2+ on :
3+ push :
4+ branches :
5+ - main
6+ - master
7+ pull_request :
8+
9+ permissions :
10+ contents : read
11+
12+ env :
13+ CGO_ENABLED : 0
14+
15+ jobs :
16+ cross :
17+ name : Go
18+ strategy :
19+ matrix :
20+ go-version : [ oldstable, stable ]
21+ os : [ubuntu-latest, macos-latest, windows-latest]
22+ runs-on : ${{ matrix.os }}
23+ steps :
24+ - uses : actions/checkout@v4
25+ - uses : actions/setup-go@v5
26+ with :
27+ go-version : ${{ matrix.go-version }}
28+
29+ - name : Test
30+ run : make test
31+
32+ - name : Build
33+ run : make build
34+
35+ - name : Vet integration
36+ run : make vet
Original file line number Diff line number Diff line change 1+ .idea /
2+ /go-printf-func-name
Original file line number Diff line number Diff line change 1+ linters :
2+ disable-all : true
3+ enable :
4+ - asasalint
5+ - asciicheck
6+ - bidichk
7+ - containedctx
8+ - contextcheck
9+ # - copyloopvar
10+ - cyclop
11+ - dogsled
12+ - dupl
13+ - dupword
14+ - durationcheck
15+ - err113
16+ - errcheck
17+ - errname
18+ - errorlint
19+ - fatcontext
20+ - forbidigo
21+ - funlen
22+ - gci
23+ - gocheckcompilerdirectives
24+ - gochecknoglobals
25+ - gochecknoinits
26+ - gocognit
27+ - goconst
28+ - gocritic
29+ - gocyclo
30+ - godot
31+ - godox
32+ - gofmt
33+ - gofumpt
34+ - goimports
35+ - gomoddirectives
36+ - gomodguard
37+ - goprintffuncname
38+ - gosec
39+ - gosimple
40+ - govet
41+ - importas
42+ - inamedparam
43+ - ineffassign
44+ - interfacebloat
45+ # - intrange
46+ - ireturn
47+ - loggercheck
48+ - maintidx
49+ - makezero
50+ - mirror
51+ - misspell
52+ - musttag
53+ - nestif
54+ - nilerr
55+ - nlreturn
56+ - noctx
57+ - nolintlint
58+ - nonamedreturns
59+ - perfsprint
60+ - predeclared
61+ - reassign
62+ - revive
63+ - staticcheck
64+ - stylecheck
65+ - tagalign
66+ - tagliatelle
67+ - tenv
68+ - testableexamples
69+ - testifylint
70+ - thelper
71+ - tparallel
72+ - unconvert
73+ - unparam
74+ - unused
75+ - usestdlibvars
76+ - wastedassign
77+ - whitespace
78+ - wrapcheck
79+ - wsl
80+
81+ linters-settings :
82+ stylecheck :
83+ checks : ['*', '-ST1000']
84+ cyclop :
85+ max-complexity : 15
86+
87+ issues :
88+ exclude-use-default : false
89+ max-issues-per-linter : 0
90+ max-same-issues : 0
91+ exclude-rules :
92+ - linters :
93+ - revive
94+ text : " package-comments: should have a package comment"
95+ - linters :
96+ - revive
97+ text : " exported: .+ should have comment or be unexported"
98+ - path : pkg/analyzer/analyzer.go
99+ linters :
100+ - gochecknoglobals
101+ text : " Analyzer is a global variable"
102+
103+ output :
104+ show-stats : true
105+ sort-results : true
106+ sort-order :
107+ - linter
108+ - file
Original file line number Diff line number Diff line change 11MIT License
22
3+ Copyright (c) 2024 Golangci-lint authors
34Copyright (c) 2020 Isaev Denis
45
56Permission is hereby granted, free of charge, to any person obtaining a copy
Original file line number Diff line number Diff line change 1+ .PHONY : lint test build vet
2+
3+ default : lint test vet
4+
5+ test :
6+ go test -v -cover ./...
7+
8+ lint :
9+ golangci-lint run
10+
11+ build :
12+ go build ./cmd/go-printf-func-name/
13+
14+ vet : build
15+ go vet -vettool=./go-printf-func-name ./...
Original file line number Diff line number Diff line change 22
33The Go linter ` go-printf-func-name ` checks that printf-like functions are named with ` f ` at the end.
44
5- For example, ` myLog ` should be named ` myLogf ` by Go convention:
5+ ## Example
6+
7+ ` myLog ` should be named ` myLogf ` by Go convention:
68
79``` go
810package main
@@ -14,3 +16,8 @@ func myLog(format string, args ...interface{}) {
1416 log.Printf (prefix + format, args...)
1517}
1618```
19+
20+ ``` console
21+ $ go vet -vettool=$( which go-printf-func-name) ./...
22+ ./main.go:5:1: printf-like formatting function 'myLog' should be named 'myLogf'
23+ ```
Original file line number Diff line number Diff line change 11module github.com/jirfag/go-printf-func-name
22
3- go 1.13
3+ go 1.22.0
44
5- require golang.org/x/tools v0.0.0-20191108193012-7d206e10da11
5+ require golang.org/x/tools v0.26.0
6+
7+ require (
8+ golang.org/x/mod v0.21.0 // indirect
9+ golang.org/x/sync v0.8.0 // indirect
10+ )
Original file line number Diff line number Diff line change 1- golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 /go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w =
2- golang.org/x/net v0.0.0-20190620200207-3b0461eec859 /go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s =
3- golang.org/x/sync v0.0.0-20190423024810-112230192c58 /go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM =
4- golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a /go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY =
5- golang.org/x/text v0.3.0 /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
6- golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E =
7- golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 /go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo =
8- golang.org/x/tools v0.0.0-20191109212701-97ad0ed33101 h1:LCmXVkvpQCDj724eX6irUTPCJP5GelFHxqGSWL2D1R0 =
9- golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 /go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0 =
1+ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI =
2+ github.com/google/go-cmp v0.6.0 /go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY =
3+ golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0 =
4+ golang.org/x/mod v0.21.0 /go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY =
5+ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ =
6+ golang.org/x/sync v0.8.0 /go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk =
7+ golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ =
8+ golang.org/x/tools v0.26.0 /go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0 =
Original file line number Diff line number Diff line change @@ -4,10 +4,9 @@ import (
44 "go/ast"
55 "strings"
66
7+ "golang.org/x/tools/go/analysis"
78 "golang.org/x/tools/go/analysis/passes/inspect"
89 "golang.org/x/tools/go/ast/inspector"
9-
10- "golang.org/x/tools/go/analysis"
1110)
1211
1312var Analyzer = & analysis.Analyzer {
@@ -18,12 +17,13 @@ var Analyzer = &analysis.Analyzer{
1817}
1918
2019func run (pass * analysis.Pass ) (interface {}, error ) {
21- inspector := pass .ResultOf [inspect .Analyzer ].(* inspector.Inspector )
20+ insp := pass .ResultOf [inspect .Analyzer ].(* inspector.Inspector )
21+
2222 nodeFilter := []ast.Node {
2323 (* ast .FuncDecl )(nil ),
2424 }
2525
26- inspector .Preorder (nodeFilter , func (node ast.Node ) {
26+ insp .Preorder (nodeFilter , func (node ast.Node ) {
2727 funcDecl := node .(* ast.FuncDecl )
2828
2929 if res := funcDecl .Type .Results ; res != nil && len (res .List ) != 0 {
You can’t perform that action at this time.
0 commit comments