1
1
# gomoddirectives
2
2
3
+ A linter that handle directives into ` go.mod ` .
4
+
3
5
[ ![ Sponsor] ( https://img.shields.io/badge/Sponsor%20me-%E2%9D%A4%EF%B8%8F-pink )] ( https://github.com/sponsors/ldez )
4
6
[ ![ Build Status] ( https://github.com/ldez/gomoddirectives/workflows/Main/badge.svg?branch=master )] ( https://github.com/ldez/gomoddirectives/actions )
5
7
6
- A linter that handle directives into ` go.mod ` .
8
+ ## Usage
9
+
10
+ ### Inside golangci-lint
11
+
12
+ Recommended.
13
+
14
+ ``` yml
15
+ linters-settings :
16
+ gomoddirectives :
17
+ # Allow local `replace` directives.
18
+ # Default: false
19
+ replace-local : true
20
+
21
+ # List of allowed `replace` directives.
22
+ # Default: []
23
+ replace-allow-list :
24
+ - launchpad.net/gocheck
25
+ # Allow to not explain why the version has been retracted in the `retract` directives.
26
+ # Default: false
27
+ retract-allow-no-explanation : true
28
+
29
+ # Forbid the use of the `exclude` directives.
30
+ # Default: false
31
+ exclude-forbidden : true
32
+
33
+ # Forbid the use of the `toolchain` directive.
34
+ # Default: false
35
+ toolchain-forbidden : true
36
+
37
+ # Forbid the use of the `tool` directives.
38
+ # Default: false
39
+ tool-forbidden : true
40
+
41
+ # Forbid the use of the `godebug` directive.
42
+ # Default: false
43
+ go-debug-forbidden : true
44
+
45
+ # Defines a pattern to validate `go` minimum version directive.
46
+ # Default: '' (no match)
47
+ go-version-pattern : ' \d\.\d+(\.0)?'
48
+ ` ` `
49
+
50
+ ### As a CLI
51
+
52
+ ` ` `
53
+ gomoddirectives [flags]
54
+
55
+ Flags :
56
+ -exclude
57
+ Forbid the use of exclude directives
58
+ -godebug
59
+ Forbid the use of godebug directives
60
+ -goversion string
61
+ Pattern to validate go min version directive
62
+ -h Show this help.
63
+ -list value
64
+ List of allowed replace directives
65
+ -local
66
+ Allow local replace directives
67
+ -retract-no-explanation
68
+ Allow to use retract directives without explanation
69
+ -tool
70
+ Forbid the use of tool directives
71
+ -toolchain
72
+ Forbid the use of toolchain directive
73
+ ```
74
+
75
+ ## Details
7
76
8
- ## [ ` retract ` ] ( https://golang.org/ref/mod#go-mod-file-retract ) directives
77
+ ### [ ` retract ` ] ( https://golang.org/ref/mod#go-mod-file-retract ) directives
9
78
10
79
- Force explanation for ` retract ` directives.
11
80
@@ -23,7 +92,7 @@ retract (
23
92
)
24
93
```
25
94
26
- ## [ ` replace ` ] ( https://golang.org/ref/mod#go-mod-file-replace ) directives
95
+ ### [ ` replace ` ] ( https://golang.org/ref/mod#go-mod-file-replace ) directives
27
96
28
97
- Ban all ` replace ` directives.
29
98
- Allow only local ` replace ` directives.
@@ -43,7 +112,7 @@ require (
43
112
replace github.com /ldez/grignotin => ../grignotin/
44
113
```
45
114
46
- ## [ ` exclude ` ] ( https://golang.org/ref/mod#go-mod-file-exclude ) directives
115
+ ### [ ` exclude ` ] ( https://golang.org/ref/mod#go-mod-file-exclude ) directives
47
116
48
117
- Ban all ` exclude ` directives.
49
118
@@ -62,7 +131,7 @@ exclude (
62
131
)
63
132
```
64
133
65
- ## [ ` tool ` ] ( https://golang.org/ref/mod#go-mod-file-tool ) directives
134
+ ### [ ` tool ` ] ( https://golang.org/ref/mod#go-mod-file-tool ) directives
66
135
67
136
- Ban all ` tool ` directives.
68
137
@@ -77,7 +146,7 @@ tool (
77
146
)
78
147
```
79
148
80
- ## [ ` toolchain ` ] ( https://golang.org/ref/mod#go-mod-file-toolchain ) directive
149
+ ### [ ` toolchain ` ] ( https://golang.org/ref/mod#go-mod-file-toolchain ) directive
81
150
82
151
- Ban ` toolchain ` directive.
83
152
@@ -89,7 +158,7 @@ go 1.22
89
158
toolchain go1.23.3
90
159
```
91
160
92
- ## [ ` godebug ` ] ( https://go.dev/ref/mod#go-mod-file-godebug ) directives
161
+ ### [ ` godebug ` ] ( https://go.dev/ref/mod#go-mod-file-godebug ) directives
93
162
94
163
- Ban ` godebug ` directive.
95
164
@@ -105,7 +174,7 @@ godebug (
105
174
)
106
175
```
107
176
108
- ## [ ` go ` ] ( https://go.dev/ref/mod#go-mod-file-go ) directive
177
+ ### [ ` go ` ] ( https://go.dev/ref/mod#go-mod-file-go ) directive
109
178
110
179
- Use a regular expression to constraint the Go minimum version.
111
180
0 commit comments