We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Go, a method defined on a pointer like this:
func (u *User) SayHello() {...}
May be called on a pointer or on an instance:
user1 := &User{Name: "Michel"} user1.SayHello() user2 := User{Name: "Michel"} user2.SayHello()
But this is not the case in Anko, as following example demonstrates:
package main import ( "fmt" "log" "github.com/mattn/anko/env" "github.com/mattn/anko/vm" ) type User struct { Name string } func (u *User) SayHello() { fmt.Printf("Hello %s!\n", u.Name) } func main() { e := env.NewEnv() user := User{Name: "Michel"} user.SayHello() err := e.Define("user", user) if err != nil { log.Fatalf("Define error: %v\n", err) } _, err = vm.Execute(e, nil, "user.SayHello()") if err != nil { log.Fatalf("Execute error: %v\n", err) } }
Which prints:
$ go run main.go Hello Michel! 2022/01/12 18:42:13 Execute error: no member named 'SayHello' for struct exit status 1
The text was updated successfully, but these errors were encountered:
Call pointer receiver method in struct passed by value.
aa6e508
An attempt to fix issue mattn#351
No branches or pull requests
In Go, a method defined on a pointer like this:
May be called on a pointer or on an instance:
But this is not the case in Anko, as following example demonstrates:
Which prints:
The text was updated successfully, but these errors were encountered: