This is a created article in which the information may have evolved or changed.
After declaring a new type, you need to answer a question before declaring a method of that type: what is the nature of this type. If this type adds or deletes a value, do you want to create a new value or change the current value? If you are creating a new value, the method for that type is to use the value passed by. If you modify the current value and use the pointer recipient, the answer will affect the way the program internally passes this type: whether it is passed by value or by pointer. It is important to maintain consistency of delivery. The principle behind this is not just to focus on the value of how a place is handled, but to pay attention to what it is worth (essentially).
5.3.1 Built-in types
A built-in type is a set of types provided by the language. We've seen these types, respectively, as numeric types, string types, and Boolean types. These types are essentially (primitive types)?. Therefore, when the party adds or deletes these values, a new value is created. Based on this conclusion, when you pass these types of values to a method or function, you should pass one (the corresponding worthy copy).
5.3.2 Reference types
There are several types of Go languages: slices, mappings, channels, interfaces, and function types. When declaring variables of the above type, the variables created are called (header values). From the technical details (the string is also a reference type)? Each reference type creates a header value that contains a pointer to the underlying data structure. Each reference type also includes a special set of fields (for managing the underlying data structure)? {Management mode}. Because the header value is designed for replication, you never need to share a value of a reference type. The header value contains a pointer, so copying to pass a worthwhile copy of a reference type is essentially sharing the underlying data.