Last active
June 16, 2023 08:21
-
-
Save Integralist/f2cb72380a7e3c3e8363dba698ab9926 to your computer and use it in GitHub Desktop.
[Go call method directly] This uses 'method expressions' #go #golang #method #expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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