Last active
August 12, 2018 01:31
-
-
Save suzuki-shunsuke/e633a8503e27170abadffb9c4705b216 to your computer and use it in GitHub Desktop.
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.org/p/2LBJbIBVw37 | |
package main | |
import ( | |
"fmt" | |
) | |
type Foo struct { | |
name string | |
} | |
func (foo *Foo) Name() string { | |
return foo.name | |
} | |
type Bar struct { | |
Name func() string | |
} | |
func main() { | |
foo := &Foo{name: "hello"} | |
bar := Bar{Name: foo.Name} | |
fmt.Println(bar.Name()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment