ARTICLE AD BOX
I'm trying to use a generic function to make a value, conforming to a specified interface. It won't compile because one of the methods takes a pointer receiver.
Code:
package main // implyType is one of many types that may be used with the generic function. type implType struct { value string } func (s implType) Get() string { return s.value } func (s *implType) Set(v string) { s.value = v } type stringGetSetter interface { Get() string Set(string) } func makeZero[T stringGetSetter]() T { var value T return value } func main() { value := makeZero[implType]() _ = value }This fails to compile with the following error:
./main.go:27:20: implType does not satisfy stringGetSetter (method Set has pointer receiver)
This is stripped-down example that shows the issue.
