Commit ac01e6b9 authored by Boris Mühmer (ADESTIS)'s avatar Boris Mühmer (ADESTIS) 💬
Browse files

added very simple reflection example

parent 4bc2fd32
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
package reflection

type example struct {
	f1 string
	x1 int
	x2 int
	f2 string
}
+16 −0
Original line number Diff line number Diff line
package reflection

import (
	"reflect"
	"testing"
)

func TestReflection1(t *testing.T) {
	e := example{}
	eT := reflect.TypeOf(e)
	t.Logf("%s", eT)
	for i := 0; i < eT.NumField(); i++ {
		f := eT.Field(i)
		t.Logf("field: %s - %s", f.Name, f.Type)
	}
}