golang - working with readCloser
In so many occasion, in this case, i worked with docker ContainerStats which return a "readCloser" type. To convert this into string, you need the code below :-
Sometimes can be tricky trying to figure which object and method to use.
containerStats, err := dc.targetClient.ContainerStats(context.Background(), dc.containerId, false)
buf := new(bytes.Buffer)
buf.ReadFrom(containerStats.Body)
fmt.Println(buf.String())
Comments