Last active
August 10, 2017 07:25
-
-
Save dhanush/70800b7d095a60923c00c56d92f01b97 to your computer and use it in GitHub Desktop.
container_read_with_skip.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reader, _ := cli.ContainerLogs(context.Background(), containerID, types.ContainerLogsOptions{ | |
ShowStdout: true, | |
Follow: true, | |
}) | |
defer reader.Close() | |
//read the first 8 bytes to ignore the HEADER part from docker container logs | |
p := make([]byte, 8) | |
reader.Read(p) | |
content, _ := ioutil.ReadAll(reader) | |
var codeOutput MyJSONStruct | |
if err := json.NewDecoder(strings.NewReader(string(content))).Decode(&codeOutput); err != nil { | |
//handle error | |
} | |
//set some other value in struct | |
codeOutput.ContainerID = containerID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you also share the struct of
MyJSONStruct
? Or maybe I missinterpret the code...