struct {
first string
last string
age int
twitter string
}
func (p Person) SetTwitterHandle(handle string) error {
if len(handle) == 0 {
p.twitter = handle // To allow an empty field
} else if len(handle) > 1 && strings.HasPrefix(handle, "@") {
p.twitter = handle
} else {
return errors.New("twitter handle must start with an '@' symbol and must be at least one character long")
}
return nil
}
"message": "ineffective assignment to field Person.twitter (SA4005)”,
"message": "ineffective assignment to field Person.twitter (SA4005)”,
because these assignments have no effect whatsoever maybe you wanted to mutate p then use *Person receiver?
Обсуждают сегодня