Skip to content

Commit 705c798

Browse files
committed
chore: new module name
1 parent 7558a9e commit 705c798

File tree

13 files changed

+235
-19
lines changed

13 files changed

+235
-19
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
go.sum linguist-generated
2+
* text=auto eol=lf
3+
*.ps1 text eol=crlf

.github/workflows/lint.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.61
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 }}

.github/workflows/tests.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
/go-printf-func-name

.golangci.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MIT License
22

3+
Copyright (c) 2024 Golangci-lint authors
34
Copyright (c) 2020 Isaev Denis
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy

Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 ./...

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
The 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
810
package 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+
```

cmd/go-printf-func-name/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"flag"
55

6-
"github.com/jirfag/go-printf-func-name/pkg/analyzer"
6+
"github.com/golangci/go-printf-func-name/pkg/analyzer"
77
"golang.org/x/tools/go/analysis/singlechecker"
88
)
99

go.mod

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
module github.com/jirfag/go-printf-func-name
1+
module github.com/golangci/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+
)

go.sum

+8-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/analyzer/analyzer.go

+4-4
Original file line numberDiff line numberDiff 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

1312
var Analyzer = &analysis.Analyzer{
@@ -18,12 +17,13 @@ var Analyzer = &analysis.Analyzer{
1817
}
1918

2019
func 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 {

pkg/analyzer/analyzer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/jirfag/go-printf-func-name/pkg/analyzer"
8+
"github.com/golangci/go-printf-func-name/pkg/analyzer"
99
"golang.org/x/tools/go/analysis/analysistest"
1010
)
1111

0 commit comments

Comments
 (0)