File tree 8 files changed +29
-6
lines changed
8 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -478,9 +478,10 @@ type GofumptSettings struct {
478
478
}
479
479
480
480
type GoHeaderSettings struct {
481
- Values map [string ]map [string ]string `mapstructure:"values"`
482
- Template string `mapstructure:"template"`
483
- TemplatePath string `mapstructure:"template-path"`
481
+ Values map [string ]map [string ]string `mapstructure:"values"`
482
+ Template string `mapstructure:"template"`
483
+ TemplatePath string `mapstructure:"template-path"`
484
+ LintConfigDir string `mapstructure:"lint-config-dir"`
484
485
}
485
486
486
487
type GoImportsSettings struct {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package golinters
2
2
3
3
import (
4
4
"go/token"
5
+ "path/filepath"
5
6
"sync"
6
7
7
8
goheader "github.com/denis-tingaikin/go-header"
@@ -21,10 +22,14 @@ func NewGoHeader(settings *config.GoHeaderSettings) *goanalysis.Linter {
21
22
22
23
conf := & goheader.Configuration {}
23
24
if settings != nil {
25
+ path := settings .TemplatePath
26
+ if path != "" && ! filepath .IsAbs (path ) {
27
+ path = filepath .Join (settings .LintConfigDir , path )
28
+ }
24
29
conf = & goheader.Configuration {
25
30
Values : settings .Values ,
26
31
Template : settings .Template ,
27
- TemplatePath : settings . TemplatePath ,
32
+ TemplatePath : path ,
28
33
}
29
34
}
30
35
Original file line number Diff line number Diff line change @@ -247,6 +247,10 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
247
247
if stylecheckCfg != nil && stylecheckCfg .GoVersion != "" {
248
248
stylecheckCfg .GoVersion = trimGoVersion (m .cfg .Run .Go )
249
249
}
250
+
251
+ if goheaderCfg != nil {
252
+ goheaderCfg .LintConfigDir = m .cfg .GetConfigDir ()
253
+ }
250
254
}
251
255
252
256
const megacheckName = "megacheck"
Original file line number Diff line number Diff line change
1
+ MY {{title}}
Original file line number Diff line number Diff line change
1
+ linters-settings :
2
+ goheader :
3
+ template-path : go-header-template
4
+ values :
5
+ const :
6
+ title : TITLE.
Original file line number Diff line number Diff line change 1
1
linters-settings :
2
2
goheader :
3
- template : MY {{title}}
3
+ template : " MY {{title}}"
4
4
values :
5
5
const :
6
6
title : TITLE.
Original file line number Diff line number Diff line change
1
+ /*MY TITLE.*/
2
+
3
+ //golangcitest:args -Egoheader
4
+ //golangcitest:config_path testdata/configs/go-header-template.yml
5
+ //golangcitest:expected_exitcode 0
6
+ package testdata
Original file line number Diff line number Diff line change 1
- /*MY TITLE! */ // want `Expected:TITLE\., Actual: TITLE! `
1
+ /*MY TITLE? */ // want `Expected:TITLE\., Actual: TITLE? `
2
2
3
3
//golangcitest:args -Egoheader
4
4
//golangcitest:config_path testdata/configs/go-header.yml
You can’t perform that action at this time.
0 commit comments