Golang functions pass pointers and pass structures. How does the inside of the function mask the details?

  golang, question
func main(){
 
 type ColorGroup struct {
 ID     int
 Name   string
 Colors []string
 }
 group := ColorGroup{
 ID:     1,
 Name:   "Reds",
 Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
 }
 //The first way
 b, err := json.Marshal(&group)
 //The second way
 b, err := json.Marshal(group)
 if err !  = nil {
 fmt.Println("error:", err)
 }
 os.Stdout.Write(b)
 }

//The first way

b, err := json.Marshal(&group)

//The second way

b, err := json.Marshal(group)

The running results are: {“ID”: 1, “Name”: “Reds”, “Colors”: [“Crimson”, “Red”, “Ruby”, “Maroon”]}

The B results obtained by these two methods are the same. go is the value transfer, the first is the copy of the transfer pointer, and the second is the copy of the transfer structure.
Then I think the problem is how to mask the details of the Marshall function that can receive different parameters.

Why can pass pointers and structures achieve the same effect?

Go foundation is not good, thank you for your advice.

  • viaReflectionWe can know what participation is.Kind.
  • Structure pointer and structure, rightMarshalFunction is no different,ElemThe function can access the structure Value pointed to by the pointer through the structure pointer.