Hi,
No, it’s not correct. You create a struct function then you call it by referencing through the struct itself and pass it a Etc object to fulfill the receiver parameter !! Why would you pass a Etc object to generate one without using it ?
The correct way would be :
package main
import (
"fmt"
)
type Etc struct {
Foo string
Bar int
}
func Make(foo string, bar int) Etc {
return Etc{
Foo: foo,
Bar: bar,
}
}
func main() {
fmt.Printf("%#+v\n", Make("foo_string", 0xbeef))
}
Have a nice day.