Is there a reason why I should create a structure using &StructName{}instead Struct{}? I see a lot of examples of the use of the former syntax even on the page " Effective the beginning," but I really can not understand why.
Additional notes: I'm not sure if I explained my problem well with these two approaches, so let me clarify my question.
I know that with help &I will get a pointer instead of a value, however I would like to know why I would use &StructName{}instead StructName{}. For example, are there any advantages to using:
func NewJob(command string, logger *log.Logger) *Job {
return &Job{command, logger}
}
instead:
func NewJob(command string, logger *log.Logger) Job {
return Job{command, logger}
}