File tree 5 files changed +63
-2
lines changed
5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -297,6 +297,7 @@ linters-settings:
297
297
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
298
298
299
299
# enable or disable analyzers by name
300
+ # run `go tool vet help` to see all analyzers
300
301
enable :
301
302
- atomicalign
302
303
enable-all : false
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
15
15
_ "golang.org/x/tools/go/analysis/passes/ctrlflow" // unused, internal analyzer
16
16
"golang.org/x/tools/go/analysis/passes/deepequalerrors"
17
17
"golang.org/x/tools/go/analysis/passes/errorsas"
18
+ "golang.org/x/tools/go/analysis/passes/fieldalignment"
18
19
"golang.org/x/tools/go/analysis/passes/findcall"
19
20
"golang.org/x/tools/go/analysis/passes/httpresponse"
20
21
"golang.org/x/tools/go/analysis/passes/ifaceassert"
55
56
copylock .Analyzer ,
56
57
deepequalerrors .Analyzer ,
57
58
errorsas .Analyzer ,
59
+ fieldalignment .Analyzer ,
58
60
findcall .Analyzer ,
59
61
httpresponse .Analyzer ,
60
62
ifaceassert .Analyzer ,
Original file line number Diff line number Diff line change @@ -238,7 +238,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
238
238
linter .NewConfig (golinters .NewMaligned ()).
239
239
WithLoadForGoAnalysis ().
240
240
WithPresets (linter .PresetPerformance ).
241
- WithURL ("https://github.com/mdempsky/maligned" ),
241
+ WithURL ("https://github.com/mdempsky/maligned" ).
242
+ Deprecated ("The repository of the linter has been archived by the owner. Use govet 'fieldalignment' instead." ),
242
243
linter .NewConfig (golinters .NewDepguard ()).
243
244
WithLoadForGoAnalysis ().
244
245
WithPresets (linter .PresetStyle ).
Original file line number Diff line number Diff line change
1
+ //args: -Egovet
2
+ //config: linters-settings.govet.enable=fieldalignment
3
+ package testdata
4
+
5
+ type gvfaGood struct {
6
+ y int32
7
+ x byte
8
+ z byte
9
+ }
10
+
11
+ type gvfaBad struct { // ERROR "struct of size 12 could be 8"
12
+ x byte
13
+ y int32
14
+ z byte
15
+ }
16
+
17
+ type gvfaPointerGood struct {
18
+ P * int
19
+ buf [1000 ]uintptr
20
+ }
21
+
22
+ type gvfaPointerBad struct { // ERROR "struct with 8008 pointer bytes could be 8"
23
+ buf [1000 ]uintptr
24
+ P * int
25
+ }
26
+
27
+ type gvfaPointerSorta struct {
28
+ a struct {
29
+ p * int
30
+ q uintptr
31
+ }
32
+ b struct {
33
+ p * int
34
+ q [2 ]uintptr
35
+ }
36
+ }
37
+
38
+ type gvfaPointerSortaBad struct { // ERROR "struct with 32 pointer bytes could be 24"
39
+ a struct {
40
+ p * int
41
+ q [2 ]uintptr
42
+ }
43
+ b struct {
44
+ p * int
45
+ q uintptr
46
+ }
47
+ }
48
+
49
+ type gvfaZeroGood struct {
50
+ a [0 ]byte
51
+ b uint32
52
+ }
53
+
54
+ type gvfaZeroBad struct { // ERROR "struct of size 8 could be 4"
55
+ a uint32
56
+ b [0 ]byte
57
+ }
Original file line number Diff line number Diff line change 1
- //args: -Emaligned
1
+ //args: -Emaligned --internal-cmd-test
2
2
package testdata
3
3
4
4
type BadAlignedStruct struct { // ERROR "struct of size 24 bytes could be of size 16 bytes"
You can’t perform that action at this time.
0 commit comments