go learn 03 basic knowledge variable type

1. In the go language, the declared statements mainly include

  • var means to declare a variable, the value can be changed, and the variable can be dynamically assigned
  • const means to declare a constant, the value is fixed, and the constant cannot be dynamically assigned
  • func means to declare a function
  • type indicates the declaration type

 2. Introduction of important keywords

  • iota is mainly used for assignment in constants, the initial value is 0, and it is incremented sequentially

 Note: When calling iota at the beginning, it is 0, but not every call will become the initialized state

 3. Meaning of special symbols

3.1 The first is the fmt package, which includes the usage of printing functions

  • %T prints the type of the output variable, pay attention to use the Printf function for output

  •  %v Outputs the value of the variable in a visible form, this v is lowercase

  •  %#v outputs the value according to the format, for example, if the current value is a string, it wraps the value in double quotes

if straight type

 It is based on the type of your value and the format in which to output it.

  • % d output decimal
  • % b output binary
  • % o output octal
  • % x output hexadecimal
  • % c output byte type
  • %U The output code point type is Unicode

Guess you like

Origin blog.csdn.net/weixin_39237340/article/details/126043877