Skip to content

Instantly share code, notes, and snippets.

@vodrazka
Created April 28, 2016 19:54
Show Gist options
  • Save vodrazka/0c7e76f793b1082d90b038d2de83f628 to your computer and use it in GitHub Desktop.
Save vodrazka/0c7e76f793b1082d90b038d2de83f628 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"reflect"
)
func main() {
var m Foo = MyStruct{"test"}
_ = m.DoSmth()
fmt.Println()
fmt.Println(reflect.TypeOf(m))
fmt.Printf("%T", m)
}
type Foo interface {
DoSmth() string
}
type MyStruct struct {
Data string
}
func (m MyStruct) DoSmth() string {
fmt.Printf("%v", m.Data)
return m.Data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment