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

gosimple: simplify fmt.Sprintf("%d", n) #198

Closed
opennota opened this Issue Oct 5, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@opennota
Contributor

opennota commented Oct 5, 2017

fmt.Sprintf("%d", n) -> fmt.Sprint(n) if n is of an int type.

@dominikh

This comment has been minimized.

Show comment
Hide comment
@dominikh

dominikh Oct 5, 2017

Owner

I'm not sure that's a suggestion we should make. The original version is more explicit about its intent, and can be checked by go vet for correctness.

/cc @shurcooL

Owner

dominikh commented Oct 5, 2017

I'm not sure that's a suggestion we should make. The original version is more explicit about its intent, and can be checked by go vet for correctness.

/cc @shurcooL

@dmitshur

This comment has been minimized.

Show comment
Hide comment
@dmitshur

dmitshur Oct 5, 2017

Contributor

Not always applicable, the original form may be used for consistency, e.g.:

s += fmt.Sprintf("...%d", n)
s += fmt.Sprintf("..%d", n)
s += fmt.Sprintf(".%d", n)
s += fmt.Sprintf("%d", n)

But of course it's a valid in-editor suggestion.

Also, it has addition alternative simplifications possible, e.g., strconv.Itoa.

Contributor

dmitshur commented Oct 5, 2017

Not always applicable, the original form may be used for consistency, e.g.:

s += fmt.Sprintf("...%d", n)
s += fmt.Sprintf("..%d", n)
s += fmt.Sprintf(".%d", n)
s += fmt.Sprintf("%d", n)

But of course it's a valid in-editor suggestion.

Also, it has addition alternative simplifications possible, e.g., strconv.Itoa.

@opennota

This comment has been minimized.

Show comment
Hide comment
@opennota

opennota Oct 5, 2017

Contributor

Also, it has addition alternative simplifications possible, e.g., strconv.Itoa.

That's two letters longer than fmt.Sprint. I'd prefer fmt.Sprint unless it's performance critical. And we already have imported fmt.

Contributor

opennota commented Oct 5, 2017

Also, it has addition alternative simplifications possible, e.g., strconv.Itoa.

That's two letters longer than fmt.Sprint. I'd prefer fmt.Sprint unless it's performance critical. And we already have imported fmt.

@dominikh

This comment has been minimized.

Show comment
Hide comment
@dominikh

dominikh Oct 5, 2017

Owner

That's two letters longer than fmt.Sprint

We are not in the code golf business.

Owner

dominikh commented Oct 5, 2017

That's two letters longer than fmt.Sprint

We are not in the code golf business.

@dominikh

This comment has been minimized.

Show comment
Hide comment
@dominikh

dominikh Oct 9, 2017

Owner

I'm going to close this issue. It's not a simplification I want to add to gosimple.

Owner

dominikh commented Oct 9, 2017

I'm going to close this issue. It's not a simplification I want to add to gosimple.

@dominikh dominikh closed this Oct 9, 2017

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