Accessing the struct field

Hi! Help me please

type employee struct {
    name    string
    age     int
    salary  int
    address address
 emp := employee{name: "Sam", age: 31, salary: 2000, address: address}

Can I get the value of employee something like this emp[“name”] or only

Only as There are ways you can get emp["name"] to work, but it requires more code, effort, setup, etc… It depends on why you want emp["name"] to work.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.