This is a creation in Article, where the information may have evolved or changed.
Basic data types
int type
Different depending on the platform, but even int64 or int32 and int are different and need to be converted
Floating point Type
Default is Float64
Floating-point numbers are best used in the module of the math package, with = = not accurate
" Math " Math. Fdim (Math. Fdim (F1,F2)
BYTE type
One is that byte represents the alias of the Uint8, which represents a byte of the Utf-8
One is that rune represents a single Unicode character UInt32
Array
var a [+byte; [ 2 struct {x, y int32}[]*float64[3] [5int[2] [2] [2] Float64
Creation of Arrays
for I, V: = range Array { ... }
traversal of an array
Slice
Two ways to create: Slice on an array and create a new one.
var my Array [ten]int = [ten]int{1234 56789}var my Slice [ ]int = My array[:5]
slicing on an array
My Slice1: = make ([]int5) My Slice2:= make ([]int5) / / The first one is Len (), the second is cap ()my Slice3: = []int{1234 5}
directly Create
Append usage of slices
My Slice =// Note the first one can be a list, but the second must be the corresponding data type, if not used ... Scattered!
Append Usage
The slice has a copy () method, copy (Slice1, Slice2), and two slices Len can be different. In the case of different lengths, the copy section
Package Mainimport"FMT"func Add (a []int) {a[0] +=1}func AddArray (A [4]int) {a[0] +=1}func Addarray_pointer (a*[4]int) {a[0] +=1}func Main () {varARRA [4]int= [4]int{Ten,2,3,4}//ArrayAddArray (ARRA)//array is a value typeFmt. Println (ARRA)//It doesn't change here .Addarray_pointer (&arra)//Incoming Array pointersFmt. Println (ARRA)//There's been a change.A:= []int{1,2,3,4}//Defining slicesAdd (a)//cannot pass a pointer, and change itselfFmt. Println (a[0])}
! Slice is not a value type, cannot write pointer
Map type
Mymap = Make (map[string= Make (map[string= map[string ] Person info{ '1234': Person info{"1" "Jack""101,... "
Create a method
Value, OK: = My map["1234"]if OK { // False if any OK is true}
Take value
Delete (Mymap,"1234")
Delete
var mymap map[stringint = map[stringint {"123" :456,"233":445} for i,k:= range Mymap { fmt. Println (i,k) }
Traverse
mymap["113"123
Assign Value
Map is not a value type, so pointers cannot be used, and function passing is passing itself