File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ GolangCI-Lint looks for config files in the following paths from the current wor
28
28
- ` .golangci.json `
29
29
30
30
GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root.
31
+ If no configuration file has been found, GolangCI-Lint will try to find one in your home directory.
31
32
To see which config file is being used and where it was sourced from run golangci-lint with ` -v ` option.
32
33
33
34
Config options inside the file are identical to command-line options.
Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ func (r *FileReader) setupConfigFileSearch() {
170
170
171
171
// find all dirs from it up to the root
172
172
configSearchPaths := []string {"./" }
173
+
173
174
for {
174
175
configSearchPaths = append (configSearchPaths , curDir )
175
176
newCurDir := filepath .Dir (curDir )
@@ -179,13 +180,29 @@ func (r *FileReader) setupConfigFileSearch() {
179
180
curDir = newCurDir
180
181
}
181
182
183
+ // find home directory for global config
184
+ if home , err := homedir .Dir (); err != nil {
185
+ r .log .Warnf ("Can't get user's home directory: %s" , err .Error ())
186
+ } else if ! sliceContains (configSearchPaths , home ) {
187
+ configSearchPaths = append (configSearchPaths , home )
188
+ }
189
+
182
190
r .log .Infof ("Config search paths: %s" , configSearchPaths )
183
191
viper .SetConfigName (".golangci" )
184
192
for _ , p := range configSearchPaths {
185
193
viper .AddConfigPath (p )
186
194
}
187
195
}
188
196
197
+ func sliceContains (slice []string , value string ) bool {
198
+ for _ , v := range slice {
199
+ if v == value {
200
+ return true
201
+ }
202
+ }
203
+ return false
204
+ }
205
+
189
206
var errConfigDisabled = errors .New ("config is disabled by --no-config" )
190
207
191
208
func (r * FileReader ) parseConfigOption () (string , error ) {
You can’t perform that action at this time.
0 commit comments