This is a creation in Article, where the information may have evolved or changed. // Disgtinguish_new&make Project Main.go
/*
Reference type : slice channel map
differences between new and make to create reference types
New allocates a 0 value space of that size based on the size of the type, and then returns the first address of the space.
Make is translated by the compiler into a concrete creation function, which allocates memory and initializes member variables, returning objects, not pointers,
*/
Package Mainimport (. "FMT") func main () {var arr = []int{1, 2, 3, 4, 5, 6, 7, 8, 9}println (arr) var Slice1 = make ([]int, 5, ten)//Make create return is SL Ice Object Println (Slice1) Slice2: = new ([]int)//New creation Returns the slice pointer (*slice2) = Append ((*slice2), 1) Println (*SLICE2)/* Compile result
[1 2 3 4 5 6 7 8 9] [0 0 0 0 0] [1]*/var map1 = Make (Map[string]int, +) Println (MAP1) Map2: = new (Map[string]in T) (*MAP2) = map[string]int{} (*MAP2) ["Xuhe"] = 4Println ((*MAP2))/* Compile result map[]map[xuhe:4]*/}