In [ ]:
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)
In [ ]:
f, err := rootio.Open(fname)
if err != nil {
    panic(err)
}
defer f.Close()
In [ ]:
printf("keys: %#v\n", f.Keys())
In [ ]:
o, err := f.Get("tree")
if err != nil {
    panic(err)
}
t := o.(rootio.Tree)
In [ ]:
printf("tree: %q entries=%v\n", t.Name(), t.Entries())
In [ ]:
branches := t.Branches()
In [ ]:
for i,b := range branches {
    printf("b[%d]: %v\n", i, b.Name())
}
In [ ]:
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()
In [ ]:
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)
}