Golang–fmt Formatting parameters

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Original

Basic

%vthe value in a default Formatwhen printing structs, the plus flag (%+v) adds field names% #va go-syntax representation of The Value%ta go-syntax representation of the type of the value%%a literal percent sign; Consumes no value

The default format for%V is:

BOOL:%tint, int8 etc.:%duint, Uint8 etc.:%d,% #x if printed with% #vfloat32, complex , etc:%gstring:%schan:%ppointer:%p

Boolean:

%tthe Word True or false

Integer:

%bbase 2%cthe character represented by the corresponding Unicode code point%dbase 10%obase 8%qa single-quoted character Li Teral safely escaped with Go Syntax.%xbase +, with lower-case letters for A-f%xbase, with upper-case letters for a-f%u Unicode format:u+1234; Same as "u+%04x"

Floating-point and complex constituents:

%bdecimalless scientific notation with exponent a power of two,in the manner of StrConv. Formatfloat with the ' B ' format,e.g. -123456p-78%escientific notation, e.g. -1.234456e+78%escientific notation, e.g.-1.2  34456e+78%fdecimal Point and no exponent, e.g. 123.456%fsynonym for%f%g%e for large exponents,%f otherwise%g%e for large Exponents,%F otherwise

String and slice of bytes (treated equivalently with these verbs):

%sthe uninterpreted bytes of the string or Slice%qa double-quoted string safely escaped with Go Syntax%xbase, Lower-cas E, characters per Byte%xbase, upper-case, characters per byte

Pointer:

%pbase notation, with leading 0x
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.