github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/version/analyzer.go (about) 1 package version 2 3 import ( 4 "github.com/blueinnovationsgroup/can-go/pkg/dbc" 5 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis" 6 ) 7 8 func Analyzer() *analysis.Analyzer { 9 return &analysis.Analyzer{ 10 Name: "version", 11 Doc: "check that the version definition is empty", 12 Run: run, 13 } 14 } 15 16 func run(pass *analysis.Pass) error { 17 for _, def := range pass.File.Defs { 18 versionDef, ok := def.(*dbc.VersionDef) 19 if !ok { 20 continue // not a version definition 21 } 22 if len(versionDef.Version) > 0 { 23 pass.Reportf(versionDef.Pos, "version should be empty") 24 } 25 } 26 return nil 27 }