The integer

  • int

// int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.

  • int8: Range: -128 through 127.

  • int16: Range: -32768 through 32767.

  • int32(rune): Range: -2147483648 through 2147483647.

  • int64: Range: -9223372036854775808 through 9223372036854775807.

  • uint

// uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32.

  • uint8(byte): Range: 0 through 255.
  • uint16: Range: 0 through 65535.
  • uint32: Range: 0 through 4294967295.
  • uint64: Range: 0 through 18446744073709551615.

floating-point

  • Float32: Float32 is the set of all IEEE-754 32-bit floating-point numbers.
  • Float64: Float64 is the set of all IEEE-754 64-bit floating-point numbers.

The Boolean

The value of bool can only be true or false. The default value is false.

String type

The encoding of string is UTF-8 and the default value is an empty string.

The derived type

  • Pointer type
  • An array type
  • Structured type (struct)
  • Channel type (chan)
  • Function type (func)
  • Type of slice
  • Interface Type
  • Map type (Map)
package main

import "fmt"

func main(a)  {
	var v1=123
	fmt.Printf("V1 is of type %T\n",v1)

	var v2 int = 123
	fmt.Printf("V2 is of type %T\n",v2)

	var v3 float64 = 123
	fmt.Printf("V2 is of type %T\n",v3)

	var v4 = 123.0
	fmt.Printf("V2 is of type %T\n",v4)

	var v5 = "Hello"
	fmt.Printf("V5 is of type %T\n",v5)

	var v6 = 'yue'
	fmt.Printf("V6 is of type %T\n",v6)
	fmt.Printf("The value of v6 is %v\n",v6)
	fmt.Printf("The character for v6 is %c\n",v6)
	fmt.Printf("The type of 23731 is %c\n".23731)

	var v7 = (100= = (40+60))
	fmt.Printf("V7 has type %T and value %v\n",v7,v7)

	var v8 = ('yue'= =23731)
	fmt.Printf("V8 has type %T and value %v\n",v8,v8)
	fmt.Printf("The character form of 23731 is %c\n".23731)
	fmt.Printf("The numerical form of yue is %d\n".'yue')
	fmt.Printf("Yue's serial number in the character set is %d\n".'yue')}Copy the code