Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active June 16, 2023 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/f2cb72380a7e3c3e8363dba698ab9926 to your computer and use it in GitHub Desktop.
Save Integralist/f2cb72380a7e3c3e8363dba698ab9926 to your computer and use it in GitHub Desktop.
[Go call method directly] This uses 'method expressions' #go #golang #method #expressions
// https://play.golang.com/p/iPOOcSzZCe7
package main
import (
"fmt"
)
type Foo struct {
Bar string
}
func (f Foo) String() string {
return f.Bar + " stuff happens"
}
func main() {
f := Foo{Bar: "Baz"}
fmt.Println(Foo.String(f))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment