You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a program with a bit buffer and a bit count. For good reasons it makes sense for the count to be something other than int (for example, you're shifting by it a lot, so it makes sense for it to be unsigned).
package main
import "fmt"
func main() {
var bits uintptr = 5
var count uintptr = 5
fmt.Printf("%*b\n", count, bits)
}
It seems like maybe fmt should allow any integer type for the width. It's a tiny bit more effort in the code and it eliminates an annoyance for users. In my case I didn't know what BADWIDTH meant and at first thought the value was actually bad in some way. It was only when I was about to read the docs that I realized the problem was likely the type.
Update: This now works without allocation:
v := reflect.ValueOf(a[argNum])
switch v.Kind() {
case reflect.Int:
isInt = true
num = int(v.Int())
}
so we are clear to fix this. Not sure what changed, if anything. Adding to 1.6.
I am writing a program with a bit buffer and a bit count. For good reasons it makes sense for the count to be something other than int (for example, you're shifting by it a lot, so it makes sense for it to be unsigned).
prints "%!(BADWIDTH)101". http://play.golang.org/p/BGxyBdPV5E
It seems like maybe fmt should allow any integer type for the width. It's a tiny bit more effort in the code and it eliminates an annoyance for users. In my case I didn't know what BADWIDTH meant and at first thought the value was actually bad in some way. It was only when I was about to read the docs that I realized the problem was likely the type.
@robpike
The text was updated successfully, but these errors were encountered: