tools / godep

dependency tool for go
http://godoc.org/github.com/tools/godep
BSD 3-Clause "New" or "Revised" License
5.54k stars 455 forks source link

Invalid Geodeps.json generated #507

Closed netrounds-joakim closed 8 years ago

netrounds-joakim commented 8 years ago

Expected behavior

Valid JSON output when running godep save

Actual behavior

{       "ImportPath": "app",
        "GodepVersion": "v74",
        "Deps": {
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "github.com/emicklei/go-restful/log",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful/swagger",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "labix.org/v2/mgo/bson",
                        "Rev": "gustavo@niemeyer.net-20140501184651-975yyw9ipld92pji"
        ]       }
}
{       "GoVersion": "go1.6",
        "Deps": [sion": "v74",
                {       "ImportPath": "github.com/emicklei/go-restful",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful/log",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "github.com/emicklei/go-restful/swagger",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "287",bix.org/v2/mgo/bson",
                }       "Rev": "gustavo@niemeyer.net-20140501184651-975yyw9ipld92pji"
        ]
}

Steps to reproduce behavior

This is the first time I ever use godep. I'm learning Go and trying to get a nice dependency management in my Docker image.

My dockerfile (work in progress):

FROM golang:1.6

RUN apt-get update
RUN apt-get install -qq -y npm

RUN npm install -g swagger-ui

RUN mkdir -p /go/src/app
WORKDIR /go/src/app

RUN mkdir -p /go/src/app/Godeps
COPY ./Godeps /go/src/app/Godeps

RUN go get github.com/tools/godep
RUN godep restore

COPY . /go/src/app
RUN godep go build .

#RUN go-wrapper download
#RUN go-wrapper install

CMD ["go-wrapper", "run"]

EXPOSE 8080

Trying to understand how stuff works I am running this in interactive mode:

docker build -t myimage
docker run --rm -it myimage /bin/bash

# Inside the docker
go-wrapper download
godep save

Resulting in the invalid JSON.

My imports

import (
    "fmt"
    "time"
    "log"
    "net/http"
//  "strconv"
    "archive/zip"
    "os"
    "io"
    "io/ioutil"
    "strings"
    "path/filepath"
    "github.com/emicklei/go-restful"
    "github.com/emicklei/go-restful/swagger"
    "labix.org/v2/mgo/bson"
)

godep version output

godep v74 (linux/amd64/go1.6.2)

go version output

go version go1.6.2 linux/amd64

Contents of Godeps.json file

{       "ImportPath": "app",
        "GodepVersion": "v74",
        "Deps": {
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "github.com/emicklei/go-restful/log",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful/swagger",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "labix.org/v2/mgo/bson",
                        "Rev": "gustavo@niemeyer.net-20140501184651-975yyw9ipld92pji"
        ]       }
}
{       "GoVersion": "go1.6",
        "Deps": [sion": "v74",
                {       "ImportPath": "github.com/emicklei/go-restful",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "v1.2-79-g89ef8af",klei/go-restful/log",
                },      "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {       "ImportPath": "github.com/emicklei/go-restful/swagger",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                {,
                        "Comment": "287",bix.org/v2/mgo/bson",
                }       "Rev": "gustavo@niemeyer.net-20140501184651-975yyw9ipld92pji"
        ]
}
netrounds-joakim commented 8 years ago

Ugh ok... Turns out running Docker in windows (or something other reason doing this in my Docker instance) breaks the cat and more output....

The same file after install vim and opening it in that:

{
        "ImportPath": "app",
        "GoVersion": "go1.6",
        "GodepVersion": "v74",
        "Deps": [
                {
                        "ImportPath": "github.com/emicklei/go-restful",
                        "Comment": "v1.2-79-g89ef8af",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                },
                {
                        "ImportPath": "github.com/emicklei/go-restful/log",
                        "Comment": "v1.2-79-g89ef8af",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                },
                {
                        "ImportPath": "github.com/emicklei/go-restful/swagger",
                        "Comment": "v1.2-79-g89ef8af",
                        "Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
                },
                {
                        "ImportPath": "labix.org/v2/mgo/bson",
                        "Comment": "287",
                        "Rev": "gustavo@niemeyer.net-20140501184651-975yyw9ipld92pji"
                }
        ]
}