Skip to content

Commit 5d96313

Browse files
committed
docs: add Usage section
1 parent f378fe9 commit 5d96313

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

readme.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,80 @@
11
# gomoddirectives
22

3+
A linter that handle directives into `go.mod`.
4+
35
[![Sponsor](https://img.shields.io/badge/Sponsor%20me-%E2%9D%A4%EF%B8%8F-pink)](https://github.com/sponsors/ldez)
46
[![Build Status](https://github.com/ldez/gomoddirectives/workflows/Main/badge.svg?branch=master)](https://github.com/ldez/gomoddirectives/actions)
57

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
776

8-
## [`retract`](https://golang.org/ref/mod#go-mod-file-retract) directives
77+
### [`retract`](https://golang.org/ref/mod#go-mod-file-retract) directives
978

1079
- Force explanation for `retract` directives.
1180

@@ -23,7 +92,7 @@ retract (
2392
)
2493
```
2594

26-
## [`replace`](https://golang.org/ref/mod#go-mod-file-replace) directives
95+
### [`replace`](https://golang.org/ref/mod#go-mod-file-replace) directives
2796

2897
- Ban all `replace` directives.
2998
- Allow only local `replace` directives.
@@ -43,7 +112,7 @@ require (
43112
replace github.com/ldez/grignotin => ../grignotin/
44113
```
45114

46-
## [`exclude`](https://golang.org/ref/mod#go-mod-file-exclude) directives
115+
### [`exclude`](https://golang.org/ref/mod#go-mod-file-exclude) directives
47116

48117
- Ban all `exclude` directives.
49118

@@ -62,7 +131,7 @@ exclude (
62131
)
63132
```
64133

65-
## [`tool`](https://golang.org/ref/mod#go-mod-file-tool) directives
134+
### [`tool`](https://golang.org/ref/mod#go-mod-file-tool) directives
66135

67136
- Ban all `tool` directives.
68137

@@ -77,7 +146,7 @@ tool (
77146
)
78147
```
79148

80-
## [`toolchain`](https://golang.org/ref/mod#go-mod-file-toolchain) directive
149+
### [`toolchain`](https://golang.org/ref/mod#go-mod-file-toolchain) directive
81150

82151
- Ban `toolchain` directive.
83152

@@ -89,7 +158,7 @@ go 1.22
89158
toolchain go1.23.3
90159
```
91160

92-
## [`godebug`](https://go.dev/ref/mod#go-mod-file-godebug) directives
161+
### [`godebug`](https://go.dev/ref/mod#go-mod-file-godebug) directives
93162

94163
- Ban `godebug` directive.
95164

@@ -105,7 +174,7 @@ godebug (
105174
)
106175
```
107176

108-
## [`go`](https://go.dev/ref/mod#go-mod-file-go) directive
177+
### [`go`](https://go.dev/ref/mod#go-mod-file-go) directive
109178

110179
- Use a regular expression to constraint the Go minimum version.
111180

0 commit comments

Comments
 (0)