import ( "io" "os" "path/filepath" "go-hep.org/x/hep/rootio" ) fname := filepath.Join(os.Getenv("GOPATH"), "src", "go-hep.org/x/hep/rootio/testdata/small-flat-tree.root") print(fname) f, err := rootio.Open(fname) if err != nil { panic(err) } defer f.Close() printf("keys: %#v\n", f.Keys()) o, err := f.Get("tree") if err != nil { panic(err) } t := o.(rootio.Tree) printf("tree: %q entries=%v\n", t.Name(), t.Entries()) branches := t.Branches() for i,b := range branches { printf("b[%d]: %v\n", i, b.Name()) } type Data struct { Int32 int32 Str string SliceFloat64 []float64 } var data Data sc, err := rootio.NewScanner(t, &data) if err != nil { panic(err) } defer sc.Close() for sc.Next() { err := sc.Scan() if err != nil { panic(err) } printf("entry[%d]: %+v\n", sc.Entry(), data) if sc.Entry() == 9 { break } } if err := sc.Err(); err != nil && err != io.EOF { panic(err) }