At the end of the JSON and Go blog post you'll find this sample program:
package main
import (
"encoding/json"
"log"
"os"
)
func main() {
dec := json.NewDecoder(os.Stdin)
enc := json.NewEncoder(os.Stdout)
for {
var v map[string]interface{}
if err := dec.Decode(&v); err != nil {
log.Println(err)
return
}
for k := range v {
if k != "Name" {
delete(v, k)
}
}
if err := enc.Encode(&v); err != nil {
log.Println(err)
}
}
}
I compiled this with go build json_decoder.go
and then ran the program like so in bash:
echo '{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}' | json_decoder
and received this output:
{"Name":"Wednesday"}
2019/08/17 22:09:20 EOF
The first line of output is exactly what I'd expect. But where is the line 2019/08/17 22:09:20 EOF
coming from?