github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/readability/reflect-good.go (about)

     1  // +build OMIT
     2  
     3  package sample // OMIT
     4  
     5  type LayerExperiment struct{ Layer, Experiment string } // HL
     6  
     7  func (t *Layers) Slice() []LayerExperiment { // HL
     8  	return []LayerExperiment{
     9  		{"UI", t.UI},
    10  		{"Launch", t.Launch},
    11  		/* more fields */
    12  	}
    13  }
    14  
    15  func sample() { // OMIT
    16  	layers := NewLayers(s.Entries).Slice() // HL
    17  	for _, l := range layers {
    18  		if l.Experiment != "-" {
    19  			eid := &pb.ExperimentId{
    20  				Layer:        proto.String(l.Layer),
    21  				ExperimentId: proto.String(l.Experiment),
    22  			}
    23  			experimentIDs = append(experimentIDs, eid)
    24  		}
    25  	}
    26  } // OMIT