github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/readability/reflect-bad.go (about) 1 // +build OMIT 2 3 package sample // OMIT 4 5 type Layers struct { 6 UI, Launch /* more fields */ string 7 } 8 9 func sample() { // OMIT 10 layers := NewLayers(s.Entries) 11 v := reflect.ValueOf(*layers) // HL 12 r := v.Type() // type Layers // HL 13 for i := 0; i < r.NumField(); i++ { 14 if e := v.Field(i).String(); e != "-" { 15 eid := &pb.ExperimentId{ 16 Layer: proto.String(r.Field(i).Name()), 17 ExperimentId: &e, 18 } 19 experimentIDs = append(experimentIDs, eid) 20 } 21 } 22 } // OMIT