1 Make function to create an array slice
The built-in function make () provided by the go language can be used to flexibly create array slices.
Create an array slice with an initial element number of 5, with an element initial value of 0:
MySlice1: = Make ([]int, 5)
Create an array slice with an initial element number of 5, an element with an initial value of 0, and a storage space of 10 elements:
MySlice2: = Make ([]int, 5, 10)
2 Defer statements
The defer statement is called at the end of the function, even if an exception occurs after the statement runs, the defer statement is still executed.
It is important to note that if a parameter is referenced in the defer statement, the value of the parameter will be the value of the program to the defer line, which is not related to the subsequent statement. 3
The range function is a magical and interesting built-in function that you can use to iterate through arrays, slices, and dictionaries.
When used to iterate over arrays and slices, the range function returns indexes and elements;
When used to traverse a dictionary, the range function returns the key and value of the dictionary.
4 func (PS *peerset) peerswithoutblock (hash common. Hash) []*peer
struct function, preceded by a function name, is the recipient of the method