为什么不用%v打印int和string

Nothing bad will happen, but the %d verb instructs the fmt package to print is as a number (using base 10), and the %v verb means to use the default format which can be overridden.
See this example:

type MyInt intfunc (mi MyInt) String() string { return fmt.Sprint("*", int(mi), "*") }func main() { var mi MyInt = 2 fmt.Printf("%d %v", mi, mi) }

【为什么不用%v打印int和string】Output:
2 *2*

    推荐阅读