Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code optimized #382

Merged
merged 4 commits into from
Jan 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
optimized
  • Loading branch information
kingxt committed Jan 13, 2021
commit 6fc7ec1bffca91c3627fecca13a0788a563f7cad
8 changes: 4 additions & 4 deletions tools/goctl/api/format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ func GoFormatApi(c *cli.Context) error {
})
be.Add(err)
}

if be.NotNil() {
scanner.PrintError(os.Stderr, be.Err())
os.Exit(1)
}

return be.Err()
}

Expand Down Expand Up @@ -92,10 +94,7 @@ func ApiFormatByPath(apiFilePath string) error {
return err
}

if err := ioutil.WriteFile(apiFilePath, []byte(result), os.ModePerm); err != nil {
return err
}
return nil
return ioutil.WriteFile(apiFilePath, []byte(result), os.ModePerm)
}

func apiFormat(data string) (string, error) {
Expand Down Expand Up @@ -214,5 +213,6 @@ func mayInsertStructKeyword(line string, token *int) string {
if strings.Contains(noCommentLine, "`") {
return util.UpperFirst(strings.TrimSpace(line))
}

return line
}