Skip to content

Remove unnecessary string formats#1568

Merged
aboch merged 2 commits intomoby:masterfrom
liketic:refactor
Dec 29, 2016
Merged

Remove unnecessary string formats#1568
aboch merged 2 commits intomoby:masterfrom
liketic:refactor

Conversation

@liketic
Copy link
Copy Markdown
Contributor

@liketic liketic commented Nov 22, 2016

For fmt.Errorf if no arguments passed, replace it with errors.New.
For t.Fatalf if no arguments passed, replace it with t.Fatal.
For t.Errorf if no arguments passed, replace it with t.Error.
For fmt.Fprintf if no arguments passed, replace it with fmt.Fprint.
For fmt.Printf if no arguments passed, replace it with fmt.Print.
For log.Printf if no arguments passed, replace it with log.Print.

Because the previous *f are almost calls the function without format internally and do format before output, but if no arguments passed, the format is unnecessary.

Happy to hear your comments. Thanks.

Signed-off-by: Ke Li <kel@splunk.com>
Comment thread cmd/dnet/cmd.go Outdated
func runContainerCreate(c *cli.Context) {
if len(c.Args()) == 0 {
fmt.Printf("Please provide container id argument\n")
fmt.Print("Please provide container id argument\n")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fmt.Println

Comment thread cmd/dnet/cmd.go Outdated

if len(c.Args()) == 0 {
fmt.Printf("Please provide container id argument\n")
fmt.Print("Please provide container id argument\n")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fmt.Println

Comment thread cmd/proxy/proxy.go Outdated
return NewTCPProxy(frontendAddr.(*net.TCPAddr), backendAddr.(*net.TCPAddr))
default:
panic(fmt.Errorf("Unsupported protocol"))
panic(errors.New("Unsupported protocol"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be panic("Unsupported protocol")

Signed-off-by: Ke Li <kel@splunk.com>
@aboch
Copy link
Copy Markdown
Contributor

aboch commented Dec 28, 2016

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants