SpecifierDescriptionCommandOutput
%+vDefault formatting with field names (for structs) type Point struct { X, Y int } p:= Point{1, 2);fmt.Printf("%+v", p);(X:1 Y:2}
%#vGo syntax representationfmt.Printf("%#v", 10)int (10)
%vDefault formattingfmt.Printf("%v", 10)10
%bBinary representationfmt.Printf("%b", 10)Ob1010
%cCharacter representationfmt.Printf("%c", ‘a")a
%dDecimal representationfmt.Printf(“⅑d”, 10)10
%0Octal representationfmt.Printf("%o", 10)0012
%xLowercase hexadecimal representationfmt.Printf("%x", 10)a
%XUppercase hexadecimal representationfmt.Printf("%X", 10)A
%UUnicode character “U+XXXX” formatfmt.Printf("%U", ‘€’)U+20AC
%uUnicode character “&#xXXXX;” formatfmt. Printf("%u", ‘€’)8#8364;
%fFloating-point representationfmt.Printf("%f", 3.14159)3.141590
%FFloating-point representation (capital letter exponent)fmt.Printf("%F", 3.14159)3.141590
%gFloating-point representation (compact format)fmt.Printf("%g", 3.14159)3.14159
%GFloating-point representation (capital letter exponent, compact format)fmt.Printf("%G", 3.14159)3.14159
%eScientific notation (lowercase exponent)fmt.Printf("%e", 3.14159)3.141590+00
%EScientific notation (uppercase exponent)fmt.Printf("%E", 3.14159)3.141590+00
%sString representationfmt.Printf("%s", “Hello”)Hello
%pPointer representationvar x int = 10 fmt.Printf("%p", &x);0x208d40 (example memory address)
%TType of the valuefmt.Printf("%T", 10)int
%%Literal percent signfmt.Printf("%%")%