Archiving a bunch of old stuff

This commit is contained in:
Dan Buch
2015-06-22 13:15:42 -05:00
parent a6ec1d560e
commit bd1abd8734
395 changed files with 1 additions and 76 deletions

View File

@@ -0,0 +1,41 @@
package main
import (
"fmt"
"reflect"
)
type Fooer interface {
Foo(int) int
}
type Bar struct {
SomeField int
}
func (this *Bar) Foo(x int) int {
return x
}
type Baz struct {
SomeField int
}
func (this Baz) Foo(x int) int {
return x
}
func main() {
var bar, baz Fooer
bar = &Bar{
SomeField: 5,
}
baz = Baz{
SomeField: 5,
}
fmt.Println(reflect.ValueOf(baz).FieldByName("SomeField"))
fmt.Println(reflect.Indirect(reflect.ValueOf(bar)).FieldByName("SomeField"))
}