@ -206,6 +206,17 @@ Example:
` , "file-batch-exec" )
` , "file-batch-exec" )
}
}
func getGoVersion ( ) string {
goModFile , err := os . ReadFile ( "go.mod" )
if err != nil {
log . Fatalf ( ` Faild to read "go.mod": %v ` , err )
os . Exit ( 1 )
}
goModVersionRegex := regexp . MustCompile ( ` go \d+\.\d+ ` )
goModVersionLine := goModVersionRegex . Find ( goModFile )
return string ( goModVersionLine [ 3 : ] )
}
func newFileCollectorFromMainOptions ( mainOptions map [ string ] string ) ( fc * fileCollector , err error ) {
func newFileCollectorFromMainOptions ( mainOptions map [ string ] string ) ( fc * fileCollector , err error ) {
fileFilter := mainOptions [ "file-filter" ]
fileFilter := mainOptions [ "file-filter" ]
if fileFilter == "" {
if fileFilter == "" {
@ -270,7 +281,7 @@ func main() {
log . Print ( "the -d option is not supported by gitea-fmt" )
log . Print ( "the -d option is not supported by gitea-fmt" )
}
}
cmdErrors = append ( cmdErrors , giteaFormatGoImports ( files , containsString ( subArgs , "-l" ) , containsString ( subArgs , "-w" ) ) )
cmdErrors = append ( cmdErrors , giteaFormatGoImports ( files , containsString ( subArgs , "-l" ) , containsString ( subArgs , "-w" ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "GOFUMPT_PACKAGE" ) , "-extra" , "-lang" , "1.17" } , substArgs ... ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "GOFUMPT_PACKAGE" ) , "-extra" , "-lang" , getGoVersion ( ) } , substArgs ... ) ) )
case "misspell" :
case "misspell" :
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "MISSPELL_PACKAGE" ) } , substArgs ... ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "MISSPELL_PACKAGE" ) } , substArgs ... ) ) )
default :
default :