Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "go list -m -json all" produces invalid JSON #31816

Closed
bep opened this issue May 3, 2019 · 1 comment
Closed

cmd/go: "go list -m -json all" produces invalid JSON #31816

bep opened this issue May 3, 2019 · 1 comment

Comments

@bep
Copy link
Contributor

@bep bep commented May 3, 2019

I have studied the documentation/issue list carefully before posting this, assuming I'm not the first ...

▶ go version && go env
go version go1.12.2 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bep/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/bep/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/bep/dev/go/gohugoio/hugo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n6/s_85mm8d31j6yctssnmn_g1r0000gn/T/go-build159934784=/tmp/go-build -gno-record-gcc-switches -fno-common"

Running

go list -m -u -e -json all

On a repo produces something like the below (an extract), which isn't valid JSON:

{
        "Path": "github.com/gohugoio/hugo",
        "Main": true,
        "Dir": "/Users/bep/dev/go/gohugoio/hugo",
        "GoMod": "/Users/bep/dev/go/gohugoio/hugo/go.mod"
}
{
        "Path": "github.com/BurntSushi/locker",
        "Version": "v0.0.0-20171006230638-a6e239ea1c69",
        "Time": "2017-10-06T23:06:38Z",
        "Dir": "/Users/bep/go/pkg/mod/github.com/!burnt!sushi/locker@v0.0.0-20171006230638-a6e239ea1c69",
        "GoMod": "/Users/bep/go/pkg/mod/cache/download/github.com/!burnt!sushi/locker/@v/v0.0.0-20171006230638-a6e239ea1c69.mod"
}
@mvdan

This comment has been minimized.

Copy link
Member

@mvdan mvdan commented May 3, 2019

Duplicate of #27655. This is fairly standard; see https://en.wikipedia.org/wiki/JSON_streaming. In the case of a Go decoder, you'd do something like NewDecoder(stdout), and repeatedly calling Decode until you hit EOF.

@mvdan mvdan closed this May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.