Why is the address of the variable passed in when the parameter type is interface {}

 
json.Unmarshal(data, &user)

json.Unmarhsal(data, user)
Mar.05,2021

Unmarshal parses the JSON-encoded data and stores the result
in the value pointed to by v. If v is nil or not a pointer,
Unmarshal returns an InvalidUnmarshalError.

@ Mu Youzhi you've seen the function prototype, take a closer look at the code comments above

officials have made it clear why. Unmarshal parses JSON encoded data and stores the results


syntactically speaking: passing a value is only a copy of the change, and you have to pass a pointer to change it.


although we can see that the second parameter is the output parameter, its most important function is to parse the JSON data into a specified struct structure object.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48439-44cbb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48439-44cbb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?