-
-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Labels
needs-decisionWe have to decide if this check is feasible and desirableWe have to decide if this check is feasible and desirablenew-check
Description
I think it would be very good if staticcheck could flag cases where people are using fmt
for just simply converting to and from strings. It was found in my PR for fyne-io/fyne (fyne-io/fyne#2142 (comment)) that the strconv
package generally is twice as fast as the fmt
package for converting to and from strings. While it is very easy and simple to do so, I think it is a poor decision most of the time.
Below are a few examples of what I would suggest flagging:
// With a single format and equivalent format type to what is being passed.
fmt.Sprintf("%", val)
// Just passing one variable.
fmt.Sprint(val)
fmt.Sprintln(val)
// With a single format and equivalent format type to what is being passed.
fmt.Sscanf(str, "%", &val)
// Just passing one variable.
fmt.Scan(&val)
fmt.Scanln(&val)
All these cases can quite easily be changed to using strconv
for pretty big performance improvements.
ainar-g
Metadata
Metadata
Assignees
Labels
needs-decisionWe have to decide if this check is feasible and desirableWe have to decide if this check is feasible and desirablenew-check