This is a creation in Article, where the information may have evolved or changed.
Record Code First
Package Mainimport"FMT"/*declaring pointer *t is the type of a pointer variable that points to the value of type T*/Func Main () {//B: = 255//var a *int = &b//A is the int pointer, and the memory address to B//FMT. Printf ("Type of Is:%t\n", a)//FMT. PRINTLN ("Address of B is", a)// //A: =//var b *int//b This variable is a pointer variable of type int, the value of the variable, and only the int type pointer//if b = = Nil {// //the 0 value of the pointer is nil//FMT. Println ("B is", b)//B = &a//FMT. Println ("B after initialization is", B)//} //B: = 255//A: = &b//FMT. PRINTLN ("Address of B is", a)//Print B's memory address//FMT. Println ("value of B is", *a)//prints the value of B, which can be obtained by *a the pointer//B: = 255//A: = &b//FMT. PRINTLN ("Address of B is:", a)//memory address of B//FMT. Println ("Value of B is:", *a)//*a++//with a pointer plus a//FMT. PRINTLN ("New value of B is:", b)//A: = +/ -//FMT. Println ("Value of a befor func call is:", a)//B: = &a//Change (b)//pointer variable b, change the value of a, a=55,//FMT. Println ("Value of a after call is:", a) /*do not pass pointers to arrays as arguments to functions, use slices instead*/ //A: = [3]int{89, A.//Modify (&a)//Pass the address of array A, to modify//FMT. Println (a)A:= [3]int{ the, -, the} modify (a[:])//Pass in a slice of aFMT. Println (a)}//The function passes the pointer, changing the memory address of the parameter. //func Change (val *int) {//*val =//Modifying the value of an array//passes a pointer to an array, as a parameter, and modifies it//func Modify (arr *[3]int) {//(*arr) [0] =// //arr[0]=90//can also be written, this is the shorthand form above (*a) [X] can be written a[x]//}//slicing methods modifying functions//This method is the most common and best way to modify a function .... Func Modify (SLS []int) {sls[0] = the}//go does not support pointer arithmetic like C