tools / godep

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

godep breaks local development? #537

Closed joelpresence closed 6 years ago

joelpresence commented 7 years ago

Expected behavior

Thanks for making this great tool available! :-)

I don't understand how to use godep for local development of my own go app that depends both on external third party go packages as well as my own packages. I've googled and searched the README and I can't find any help on this. Can somebody please help? :-)

I've laid out my workspace according to go standards (multiple of my own go packages in the same git repo):

github.com/mystuff/mycli github.com/mystuff/mycore

OK, I commit all my code to git and then I run godep save ./... in the mycli dir which creates directories

github.com/mystuff/mycli/Godeps github.com/mystuff/mycli/vendor

and all is well. I can deploy to Heroku, AWS, etc. Great.

Then I edit some of my files locally in mycore, for example adding a new type Foo. Then I edit some files in mycli to use my new type Foo. Note that I've made changes locally and these changes are not committed to git yet (because I need to verify that they build and work correctly before committing them).

However, now my build is totally broken. Any attempt to build mycore with the new type Foo succeeds. Any attempt to build mycli results in a syntax error ./main.go:48: undefined: mycore.Foo (I updated mycli/main.go to reference the new type Foo). This is not true, mycore.Foo is perfectly well defined and compiles just fine when I go build in the mycore dir.

I was stuck unable to build my code, until I did

cd github.com/mystuff/mycli/
mv Godeps gd
mv vendor ve

# Now stuff builds just find and Foo is no longer "undefined"

So it seems that godep was somehow hiding my local changes? I tried to do godep save ./... again but godep barfed and said I had a dirty git dir and needed to commit files. But no, I can't do that - I'm not going to commit stuff in mycore and mycli just to see if it works properly in mycli - I need to build and test before committing.

So I don't understand, it seems like godep breaks local development? How, during local development, do I tell godep "hey, just use the version of mycli and mycore that are locally on disk, forget about what you think you should use from Godeps.json or vendor for my own code, but still use those fixed versions for other packages".

How do I do that? I'm a go and godep newbie, so apologies if I missed something obvious or some convention - if somebody can help me out I'd be happy to create a PR to update docs to make this more clear.

But I just can't afford to mv the godep and vendor dirs each time I need to test local changes to my own code or commit those changes before build. That's just too slow ...

Actual behavior

godep should allow local development to use local changes to my own code without interference from Godeps or vendor.

Steps to reproduce behavior

See above.

godep version output

godep v79 (darwin/amd64/go1.8)

go version output

go version go1.8 darwin/amd64

Contents of Godeps.json file

{
        "ImportPath": "github.com/mystuff/mycli",
        "GoVersion": "go1.8",
        "GodepVersion": "v79",
        "Packages": [
                "./..."
        ],
        "Deps": [
                {
                        "ImportPath": "github.com/google/uuid",
                        "Comment": "0.2-3-g6a5e285",
                        "Rev": "6a5e28554805e78ea6141142aba763936c4761c0"
                },
                {
                        "ImportPath": "github.com/mystuff/mycore",
                        "Rev": "1e2145d04ab6e124671d65990e65da5038bef84f"
                },
                {
                        "ImportPath": "github.com/pressly/chi",
                        "Comment": "v2.0.0-26-g5b7406a",
                        "Rev": "5b7406a71dbb35d4f59b0b48e68cd9f9256f5262"
                },
                {
                        "ImportPath": "github.com/pressly/chi/middleware",
                        "Comment": "v2.0.0-26-g5b7406a",
                        "Rev": "5b7406a71dbb35d4f59b0b48e68cd9f9256f5262"
                },
                {
                        "ImportPath": "github.com/pressly/chi/render",
                        "Comment": "v2.0.0-26-g5b7406a",
                        "Rev": "5b7406a71dbb35d4f59b0b48e68cd9f9256f5262"
                }
        ]
}
joelpresence commented 7 years ago

Bump. Any updates?

joelpresence commented 7 years ago

Bump. Any updates? Can somebody please help ... Thanks! :-)

fforootd commented 7 years ago

i guess you need to use "godep go build -o main" instead of "go build -o main"

joelpresence commented 7 years ago

Thanks @fforootd !

But I'm not using godep to build. I'm doing my builds inside of LiteIDE for rapid development and iteration. However, I need godep for deployment to heroku. I just need godep to not break my builds in LiteIDE. Any ideas?

freeformz commented 6 years ago

I am closing this issue because the repo is going to be archived.