diff --git a/tools/goctl/api/format/format_test.go b/tools/goctl/api/format/format_test.go index f171994d..076b25a8 100644 --- a/tools/goctl/api/format/format_test.go +++ b/tools/goctl/api/format/format_test.go @@ -65,7 +65,7 @@ func Test_apiFormatReader_issue1721(t *testing.T) { require.NoError(t, err) filename := path.Join(subDir, "bar.api") - err = ioutil.WriteFile(filename, []byte(fmt.Sprintf(`import "%s"`, importedFilename)), 0644) + err = ioutil.WriteFile(filename, []byte(fmt.Sprintf(`import "%s"`, importedFilename)), 0o644) require.NoError(t, err) f, err := os.Open(filename) diff --git a/tools/goctl/api/gogen/genhandlers.go b/tools/goctl/api/gogen/genhandlers.go index 0231fc60..5b286228 100644 --- a/tools/goctl/api/gogen/genhandlers.go +++ b/tools/goctl/api/gogen/genhandlers.go @@ -60,7 +60,8 @@ func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route } func doGenToFile(dir, handler string, cfg *config.Config, group spec.Group, - route spec.Route, handleObj handlerInfo) error { + route spec.Route, handleObj handlerInfo, +) error { filename, err := format.FileNamingFormat(cfg.NamingFormat, handler) if err != nil { return err diff --git a/tools/goctl/api/parser/g4/ast/apiparser.go b/tools/goctl/api/parser/g4/ast/apiparser.go index 214d6956..f454850b 100644 --- a/tools/goctl/api/parser/g4/ast/apiparser.go +++ b/tools/goctl/api/parser/g4/ast/apiparser.go @@ -254,7 +254,6 @@ func (p *Parser) storeVerificationInfo(api *Api) { } func (p *Parser) valid(nestedApi *Api) error { - if p.syntax != nil && nestedApi.Syntax != nil { if p.syntax.Version.Text() != nestedApi.Syntax.Version.Text() { syntaxToken := nestedApi.Syntax.Syntax diff --git a/tools/goctl/api/parser/g4/ast/apiparser_test.go b/tools/goctl/api/parser/g4/ast/apiparser_test.go index 8110c279..f873f397 100644 --- a/tools/goctl/api/parser/g4/ast/apiparser_test.go +++ b/tools/goctl/api/parser/g4/ast/apiparser_test.go @@ -25,13 +25,13 @@ func Test_ImportCycle(t *testing.T) { defer os.RemoveAll(dir) mainPath := filepath.Join(dir, mainFilename) - err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) + err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777) require.NoError(t, err) subAPath := filepath.Join(dir, subAFilename) - err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) + err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777) require.NoError(t, err) subBPath := filepath.Join(dir, subBFilename) - err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) + err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777) require.NoError(t, err) _, err = NewParser().Parse(mainPath) @@ -55,13 +55,13 @@ func Test_MultiImportedShouldAllowed(t *testing.T) { defer os.RemoveAll(dir) mainPath := filepath.Join(dir, mainFilename) - err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) + err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777) require.NoError(t, err) subAPath := filepath.Join(dir, subAFilename) - err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) + err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777) require.NoError(t, err) subBPath := filepath.Join(dir, subBFilename) - err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) + err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777) require.NoError(t, err) _, err = NewParser().Parse(mainPath) @@ -84,13 +84,13 @@ func Test_RedundantDeclarationShouldNotBeAllowed(t *testing.T) { defer os.RemoveAll(dir) mainPath := filepath.Join(dir, mainFilename) - err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0777) + err = ioutil.WriteFile(mainPath, []byte(mainSrc), 0o777) require.NoError(t, err) subAPath := filepath.Join(dir, subAFilename) - err = ioutil.WriteFile(subAPath, []byte(subASrc), 0777) + err = ioutil.WriteFile(subAPath, []byte(subASrc), 0o777) require.NoError(t, err) subBPath := filepath.Join(dir, subBFilename) - err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0777) + err = ioutil.WriteFile(subBPath, []byte(subBSrc), 0o777) require.NoError(t, err) _, err = NewParser().Parse(mainPath) diff --git a/tools/goctl/model/sql/command/migrationnotes/v1.3.4.go b/tools/goctl/model/sql/command/migrationnotes/v1.3.4.go index 8b63b173..0f5cb759 100644 --- a/tools/goctl/model/sql/command/migrationnotes/v1.3.4.go +++ b/tools/goctl/model/sql/command/migrationnotes/v1.3.4.go @@ -49,5 +49,4 @@ func needShow1_3_4(dir, style string) (bool, error) { } } return false, nil - } diff --git a/tools/goctl/model/sql/gen/gen.go b/tools/goctl/model/sql/gen/gen.go index ee55c0d7..c097a913 100644 --- a/tools/goctl/model/sql/gen/gen.go +++ b/tools/goctl/model/sql/gen/gen.go @@ -202,7 +202,8 @@ func (g *defaultGenerator) createFile(modelList map[string]*codeTuple) error { // ret1: key-table name,value-code func (g *defaultGenerator) genFromDDL(filename string, withCache bool, database string) ( - map[string]*codeTuple, error) { + map[string]*codeTuple, error, +) { m := make(map[string]*codeTuple) tables, err := parser.Parse(filename, database) if err != nil { diff --git a/tools/goctl/model/sql/gen/gen_test.go b/tools/goctl/model/sql/gen/gen_test.go index b7d8e0fe..8d50eb7f 100644 --- a/tools/goctl/model/sql/gen/gen_test.go +++ b/tools/goctl/model/sql/gen/gen_test.go @@ -131,12 +131,12 @@ func Test_genPublicModel(t *testing.T) { var err error dir := pathx.MustTempDir() modelDir := path.Join(dir, "model") - err = os.MkdirAll(modelDir, 0777) + err = os.MkdirAll(modelDir, 0o777) require.NoError(t, err) defer os.RemoveAll(dir) modelFilename := filepath.Join(modelDir, "foo.sql") - err = ioutil.WriteFile(modelFilename, []byte(source), 0777) + err = ioutil.WriteFile(modelFilename, []byte(source), 0o777) require.NoError(t, err) g, err := NewDefaultGenerator(modelDir, &config.Config{ diff --git a/tools/goctl/model/sql/gen/update.go b/tools/goctl/model/sql/gen/update.go index a4cee375..b6e1e17b 100644 --- a/tools/goctl/model/sql/gen/update.go +++ b/tools/goctl/model/sql/gen/update.go @@ -12,9 +12,10 @@ import ( ) func genUpdate(table Table, withCache, postgreSql bool) ( - string, string, error) { + string, string, error, +) { expressionValues := make([]string, 0) - var pkg = "data." + pkg := "data." if table.ContainsUniqueCacheKey { pkg = "newData." } diff --git a/tools/goctl/quickstart/micro.go b/tools/goctl/quickstart/micro.go index 08a10c0a..4d73af8e 100644 --- a/tools/goctl/quickstart/micro.go +++ b/tools/goctl/quickstart/micro.go @@ -38,7 +38,7 @@ func initRPCProto() error { protoFilename := filepath.Join(zrpcWorkDir, protoName) rpcBytes := []byte(protocContent) - return ioutil.WriteFile(protoFilename, rpcBytes, 0666) + return ioutil.WriteFile(protoFilename, rpcBytes, 0o666) } type micro struct{} @@ -55,7 +55,7 @@ func (m micro) mustStartRPCProject() { arg := "goctl rpc protoc " + protoName + " --go_out=. --go-grpc_out=. --zrpc_out=. --verbose" execCommand(zrpcWorkDir, arg) etcFile := filepath.Join(zrpcWorkDir, "etc", "greet.yaml") - logx.Must(ioutil.WriteFile(etcFile, []byte(rpcEtcContent), 0666)) + logx.Must(ioutil.WriteFile(etcFile, []byte(rpcEtcContent), 0o666)) } func (m micro) start() { diff --git a/tools/goctl/quickstart/mono.go b/tools/goctl/quickstart/mono.go index 30f5deda..e5ec5ab4 100644 --- a/tools/goctl/quickstart/mono.go +++ b/tools/goctl/quickstart/mono.go @@ -35,7 +35,7 @@ func initAPIFlags() error { apiFilename := filepath.Join(apiWorkDir, "greet.api") apiBytes := []byte(apiContent) - if err := ioutil.WriteFile(apiFilename, apiBytes, 0666); err != nil { + if err := ioutil.WriteFile(apiFilename, apiBytes, 0o666); err != nil { return err } @@ -59,7 +59,7 @@ func (m mono) createAPIProject() { log.Debug(">> Generating quickstart api project...") logx.Must(gogen.GoCommand(nil, nil)) etcFile := filepath.Join(apiWorkDir, "etc", "greet.yaml") - logx.Must(ioutil.WriteFile(etcFile, []byte(apiEtcContent), 0666)) + logx.Must(ioutil.WriteFile(etcFile, []byte(apiEtcContent), 0o666)) logicFile := filepath.Join(apiWorkDir, "internal", "logic", "pinglogic.go") svcFile := filepath.Join(apiWorkDir, "internal", "svc", "servicecontext.go") configPath := filepath.Join(apiWorkDir, "internal", "config") diff --git a/tools/goctl/quickstart/run.go b/tools/goctl/quickstart/run.go index 662b2e7d..09896af2 100644 --- a/tools/goctl/quickstart/run.go +++ b/tools/goctl/quickstart/run.go @@ -20,7 +20,7 @@ func goModTidy(dir string) int { return execCommand(dir, "go mod tidy", prepareGoProxyEnv()...) } -func execCommand(dir string, arg string, envArgs ...string) int { +func execCommand(dir, arg string, envArgs ...string) int { cmd := exec.Command("sh", "-c", arg) if runtime.GOOS == vars.OsWindows { cmd = exec.Command("cmd.exe", "/c", arg)