This is my code:
package main
import "fmt"
type Group struct {
}
func (g *Group) FooMethod() string {
return "foo"
}
type Data interface {
FooMethod() string
}
func NewJsonResponse(d Data) Data {
return d
}
func main() {
var g Group
json := NewJsonResponse(g)
fmt.Println("vim-go")
}
but does not work as I expect.
$ go build main.go
# command-line-arguments
./main.go:22: cannot use g (type Group) as type Data in argument to NewJsonResponse:
Group does not implement Data (FooMethod method has pointer receiver)