Coming from C#, this puzzles me. In Go, if I have
type Employee struct {
ID int
Salary int
}
then I can do
var tom Employee
tom.Salary = 100
so far so good. Then if I have a function
func employeeByID(id int) Employee {
// do something and return an employee
}
Then why does this not compile?
employeeByID(10).Salary = 100
Moreover, this seems to compile fine:
andrew := employeeByID(10)
andrew.Salary = 100