In go, the statement
fmt.Sprintf("%4.3f", 18.8836)
Will return
18.883
Is there a way of making the return value
18.88
In other words, is there a way to make the 4 apply to the whole width of the number and not just the decimal portion?
You can accomplish this with %g:
%g
fmt.Printf("%.4g ", 18.8836)
https://play.golang.org/p/accWeNXG9V