# Go-HEP v0.16.0: rootio is dead, long live groot

**URL:** <https://root-forum.cern.ch/t/go-hep-v0-16-0-rootio-is-dead-long-live-groot/31865>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [December 3, 2018, 3:55pm UTC](https://root-forum.cern.ch/t/go-hep-v0-16-0-rootio-is-dead-long-live-groot/31865 "2018-12-03T15:55:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [December 3, 2018, 3:55pm UTC](https://root-forum.cern.ch/t/go-hep-v0-16-0-rootio-is-dead-long-live-groot/31865/1 "2018-12-03T15:55:27Z")

</div>

hi there,

I realized I’ve talked a bit about the new `groot` package on the ROOT-forum, but didn’t properly introduce it.  
It’s part of the new Go-HEP `v0.16.0` release.

see the full announcement here:

- [https://go-hep.org/news/release-0.16.0/](https://go-hep.org/news/release-0.16.0/)

TL;DR: it’s a new package, still in [Go](https://golang.org), that presents a somewhat better API to interact with ROOT files and ROOT types from Go (and Go-HEP.)

* * *

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1886496.svg)](https://doi.org/10.5281/zenodo.1886496)

Release [`v0.16.0`](https://github.com/go-hep/hep/tree/v0.16.0) is fresh from the oven.

This new release introduces a new package, [groot](https://go-hep.org/x/hep/groot), that replaces `rootio`.

## groot & rootio

 ![groot](https://go-hep.org/images/news/release-0.16.0/groot.jpg)

`groot` is a new package that is meant to replace `rootio`.  
For backward compatibility, `rootio` will remain in the repository for a couple of releases (presumably until `v1.0.0`.)

`groot` is the result of refactoring `rootio` in a couple of more focused packages with clear API boundaries:

- [groot/rbase](https://go-hep.org/x/hep/groot/rbase): definitions of basic ROOT classes (`Object`, `Named`, `ObjString`, …)
- [groot/rbytes](https://go-hep.org/x/hep/groot/rbytes): definitions of types useful for serializing and deserializing ROOT data buffers, interfaces to interact with ROOT’s metadata classes such as `StreamerInfo` and `StreamerElement`s.
- [groot/rcont](https://go-hep.org/x/hep/groot/rcont): definitions of ROOT container types (`TList`, `THashList`, `TObjArray`, `TArrayX`)
- [groot/rdict](https://go-hep.org/x/hep/groot/rdict): definitions of ROOT streamers (`TStreamerArtificial`, `TStreamerLoop`, …)
- [groot/rhist](https://go-hep.org/x/hep/groot/rhist): definitions of ROOT types related to histograms and graphs (`TH1x`, `TH2x`, `TGraph`, `TGraphErrors`, `TGraphAsymmErrors`)
- [groot/riofs](https://go-hep.org/x/hep/groot/riofs): low-level types and functions to deal with opening and creating ROOT files; users should prefer using the [groot](https://go-hep.org/x/hep/groot) package to open and create ROOT files
- [groot/root](https://go-hep.org/x/hep/groot/root): ROOT core interfaces (`Object`, `Named`, `ObjArray`, …)
- [groot/rsrv](https://go-hep.org/x/hep/groot/rsrv): exposes HTTP end-point to manipulate ROOT files, plot and create histograms and graphs from files or trees
- [groot/rtree](https://go-hep.org/x/hep/groot/rtree): interface to decode, read, concatenate and iterate over ROOT Trees
- [groot/rtypes](https://go-hep.org/x/hep/groot/rtypes): `rtypes` contains the means to register types (ROOT ones and user defined ones) with the ROOT type factory system
- [groot/rvers](https://go-hep.org/x/hep/groot/rvers): `rvers` contains the ROOT version and the classes’ versions `groot` is supporting and currently reading.

Interacting with ROOT files should be performed with the `groot` package:

```auto
import "go-hep.org/x/hep/groot"

func F() {
	f1, err := groot.Open("some/file.root")
	f2, err := groot.Create("some/other.root")
}

```

`groot` has the needed bootstrap code that allows to automatically import the registration code for all the ROOT types `groot` knows how to handle.

Here is a quick and dirty Rosetta code for migrating to `groot`:

- `rootio.H1` → `groot/rhist.H1`
- `rootio.H2` → `groot/rhist.H2`
- `rootio.Graph` → `groot/rhist.Graph`
- `rootio.Tree` → `groot/rtree.Tree`
- `rootio.ChainOf` → `groot/rtree.ChainOf`
- `rootio.Scanner` → `groot/rtree.Scanner`
- `rootio.File` → `groot/riofs.File`
- `rootio.Directory` → `groot/riofs.Directory`
- `rootio.Open` → `groot.Open`
- `rootio.Create` → `groot.Create`

### groot/rsrv & root-srv

`root-srv` has been refactored to extract the pure plot/file interaction machinery from the GUI part.  
The plot creation and the ROOT file interaction parts have been refactored into a new package [go-hep.org/x/hep/groot/rsrv](https://go-hep.org/x/hep/groot/rsrv) that contains a couple of HTTP end-points that can be reused in third-party packages or applications.

`rsrv` exposes a REST API that expects JSON requests (`OpenFileRequest`, `PlotH1Request`, `PlotTreeRequest`, …) and returns JSON responses.  
The HTTP end-points are attached to the [rsrv.Server](https://godoc.org/go-hep.org/x/hep/groot/rsrv#Server) type.

`root-srv` can now open ROOT files served over `xrootd`.
