Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

go get does not work for a module-enabled project #240

Closed
ngortheone opened this issue May 25, 2019 · 23 comments
Closed

go get does not work for a module-enabled project #240

ngortheone opened this issue May 25, 2019 · 23 comments

Comments

@ngortheone
Copy link

@ahmdrz This is partially related to #174
I am porting https://github.com/tducasse/go-instabot to V2 version.

When I use go modules I can't install goinsta.

$ go mod init github.com/tducasse/go-instabot
go: creating new go.mod: module github.com/tducasse/go-instabot

$ go get -u -v gopkg.in/ahmdrz/goinsta.v2                                                                  *[master]
Fetching https://gopkg.in/ahmdrz/goinsta.v2?go-get=1
Parsing meta tags from https://gopkg.in/ahmdrz/goinsta.v2?go-get=1 (status code 200)
get "gopkg.in/ahmdrz/goinsta.v2": found meta tag get.metaImport{Prefix:"gopkg.in/ahmdrz/goinsta.v2", VCS:"git", RepoRoot:"https://gopkg.in/ahmdrz/goinsta.v2"} at https://gopkg.in/ahmdrz/goinsta.v2?go-get=1
go: gopkg.in/ahmdrz/goinsta.v2@v2.4.0: parsing go.mod: unexpected module path "github.com/ahmdrz/goinsta.v2"
go get: error loading module requirements

I also tried

$ go get -u -v github.com/ahmdrz/goinsta/v2
go: github.com/ahmdrz/goinsta/v2@v2.4.0: go.mod has non-.../v2 module path "github.com/ahmdrz/goinsta.v2" (and .../v2/go.mod does not exist) at revision v2.4.0
go get: error loading module requirements

$ go get -u -v github.com/ahmdrz/goinsta 
go: finding github.com/ahmdrz/goinsta latest
go: github.com/ahmdrz/goinsta@v0.0.0-20190510152949-903ea3101245: go.mod has post-v0 module path "github.com/ahmdrz/goinsta/v2" at revision 903ea3101245
go get: error loading module requirements

I can install other libs with go get without problems, so I have high confidence that this is goinsta related problem. A side node - when I use the old GOPATH way - everything works fine.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.79. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the bug label May 25, 2019
@MarlikAlmighty
Copy link

go get -u -v gopkg.in/ahmdrz/goinsta.v2
Fetching https://gopkg.in/ahmdrz/goinsta.v2?go-get=1
Parsing meta tags from https://gopkg.in/ahmdrz/goinsta.v2?go-get=1 (status code 200)
get "gopkg.in/ahmdrz/goinsta.v2": found meta tag get.metaImport{Prefix:"gopkg.in/ahmdrz/goinsta.v2", VCS:"git", RepoRoot:"https://gopkg.in/ahmdrz/goinsta.v2"} at https://gopkg.in/ahmdrz/goinsta.v2?go-get=1
go: finding gopkg.in/ahmdrz/goinsta.v2 v2.4.2
go: gopkg.in/ahmdrz/goinsta.v2@v2.4.2: go.mod has non-....v2 module path "github.com/ahmdrz/goinsta/v2" at revision v2.4.2
go get: error loading module requirements

@MarlikAlmighty
Copy link

go get -u -v github.com/ahmdrz/goinsta/v2 it works.

@ahmdrz
Copy link
Owner

ahmdrz commented Jul 28, 2019

@ngortheone Does github.com/ahmdrz/goinsta/v2 works for you now?

@ngortheone
Copy link
Author

@ahmdrz sorry, I have moved on to another project. I won't be able to verify any time soon

@falzm
Copy link

falzm commented Jul 30, 2019

go get -u -v github.com/ahmdrz/goinsta/v2

@MarlikAlmighty could you please post the actual output of your test? It doesn't on my computer:

$ go get -u -v github.com/ahmdrz/goinsta/v2
go: github.com/ahmdrz/goinsta/v2@v2.4.3: go.mod has non-.../v2 module path "github.com/ahmdrz/goinsta" (and .../v2/go.mod does not exist) at revision v2.4.3
go get: error loading module requirements

@falzm
Copy link

falzm commented Jul 30, 2019

@ahmdrz could you please try to change your module value to github.com/ahmdrz/goinsta/v2 name in your go.mod?

@MarlikAlmighty
Copy link

MarlikAlmighty commented Jul 30, 2019

go get -u -v github.com/ahmdrz/goinsta/v2

@MarlikAlmighty could you please post the actual output of your test? It doesn't on my computer:

$ go get -u -v github.com/ahmdrz/goinsta/v2
go: github.com/ahmdrz/goinsta/v2@v2.4.3: go.mod has non-.../v2 module path "github.com/ahmdrz/goinsta" (and .../v2/go.mod does not exist) at revision v2.4.3
go get: error loading module requirements
$ go get -u -v github.com/ahmdrz/goinsta/v2
go: finding github.com/ahmdrz/goinsta/v2 v2.4.3
go: github.com/ahmdrz/goinsta/v2@v2.4.3: go.mod has non-.../v2 module path "github.com/ahmdrz/goinsta" (and .../v2/go.mod does not exist) at revision v2.4.3
go get: error loading module requirements

@ahmdrz
Copy link
Owner

ahmdrz commented Jul 30, 2019

@falzm go.mod is changed but is still not working. Could you check as well?

@falzm
Copy link

falzm commented Jul 30, 2019

@ahmdrz I managed to make it work by adding the following line to my go.mod file:

replace github.com/ahmdrz/goinsta/v2 => github.com/ahmdrz/goinsta v2.4.3

Then go get -u finally pulled the latest tag:

$ go get -u github.com/ahmdrz/goinsta/v2
go: finding github.com/ahmdrz/goinsta v2.4.3

$ git diff
diff --git a/go.mod b/go.mod
index 118716b..7d2e356 100644
--- a/go.mod
+++ b/go.mod
@@ -4,9 +4,11 @@ go 1.12

 require (
        github.com/Masterminds/goutils v1.0.1
-       github.com/ahmdrz/goinsta/v2 v2.4.1-0.20190510152949-903ea3101245
+       github.com/ahmdrz/goinsta/v2 v2.4.3
        github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261 // indirect
        github.com/getsentry/raven-go v0.2.0
        github.com/gorilla/feeds v1.1.1
        github.com/pkg/errors v0.8.1
 )
+
+replace github.com/ahmdrz/goinsta/v2 => github.com/ahmdrz/goinsta v0.0.0-20190729052829-bf558a94ed9d
diff --git a/go.sum b/go.sum
index b196b5d..6768fcc 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,7 @@
 github.com/Masterminds/goutils v1.0.1 h1:upyB/JGR/aPHTE3f4O3mBIbJCr7aPup+/03IS4aXU6Y=
 github.com/Masterminds/goutils v1.0.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
+github.com/ahmdrz/goinsta v0.0.0-20190729052829-bf558a94ed9d h1:a9WkfI+kd9zEhI0KDPgRMjQNgkFSs/4GudnkHppTwAA=
+github.com/ahmdrz/goinsta v0.0.0-20190729052829-bf558a94ed9d/go.mod h1:ZDXgVWGZMWUpg9hZx5gmPmo4/XjT3vE3xFt7EG079NQ=
 github.com/ahmdrz/goinsta/v2 v2.4.1-0.20190323085700-ffd9e29a313a h1:lvtGW57Exf0L6PtsPNkKRIW9oY6bxPqVx1zr8KYTtfM=
 github.com/ahmdrz/goinsta/v2 v2.4.1-0.20190323085700-ffd9e29a313a/go.mod h1:M6/Tnc41f4gn+rl9HxFaNY1c6Px5zQWHgyY6S/wSZFs=
 github.com/ahmdrz/goinsta/v2 v2.4.1-0.20190510152949-903ea3101245 h1:W4UU/mMm1UKBCb0a+XpWPsVi3GB3aTiA1UlkwTR+VLU=

I wonder if this issue isn't due to the fact that your v2 branch is not up-to-date corresponding to master. I guess if you declare that github.com/ahmdrz/goinsta/v2 is the official import path then the corresponding Git branch must always be up-to-date (including tags).

@ahmdrz
Copy link
Owner

ahmdrz commented Jul 30, 2019

So before any tag release I have to make sure that v2 branch is synced with master branch. Right?

@falzm
Copy link

falzm commented Jul 30, 2019

So before any tag release I have to make sure that v2 branch is synced with master branch. Right?

I think so yes, but I'm not an expert in Go modules yet so I guess it's worth trying out :)

@inliquid
Copy link
Contributor

FYI: #211
@ahmdrz you have to tag new version after you change go.mod, otherwise use workaround with @master from that issue.

@ahmdrz
Copy link
Owner

ahmdrz commented Jul 31, 2019

@inliquid is go.mod correct right now?
I want to make it easy for goinsta's two branches.
v2 and v1

@inliquid
Copy link
Contributor

inliquid commented Aug 1, 2019

go.mod is correct, but go modules will look at git tags. Last tag atm is v2.4.3 which points to previous version of go.mod, which is not quite correct. So when Go tools will be fetching github.com/ahmdrz/goinsta/v2 they will automatically try @latest, turning into v2.4.3, with previous version of go.mod. It's possible to override by calling go get github.com/ahmdrz/goinsta/v2@master explicitly if we talk about some project, which depends on github.com/ahmdrz/goinsta/v2, uder the project dir (will update project's dependency in own go.mod), making it use last committed change (including go.mod of goinsta). Or you may just tag new version, say 2.4.4 and it should be fine.

@ahmdrz
Copy link
Owner

ahmdrz commented Aug 1, 2019

@inliquid Thank you.
I'm going to create a new tag. It must be v2.4.4, right? Or 2.4.4.

@inliquid
Copy link
Contributor

inliquid commented Aug 1, 2019

v2.4.4, correct.

@ahmdrz
Copy link
Owner

ahmdrz commented Aug 1, 2019

What does /v2 mean in go.mod file? What if I remove it?

@inliquid
Copy link
Contributor

inliquid commented Aug 1, 2019

Then you break those (including myself) who have import "github.com/ahmdrz/goinsta/v2" in their code if they try to update. This is quite common approach and one of the recommended by go team. Here is some more info: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

@ahmdrz
Copy link
Owner

ahmdrz commented Aug 1, 2019

I see. Thank you.
Could you check it now? v2.4.4 is available.

@inliquid
Copy link
Contributor

inliquid commented Aug 1, 2019

Yes, it's fine now. I tried both v2 dependency for my project and v1, for that I used github.com/borteo/ermes which uses govendor tool for vendoring. After cloning repo, vendor.json dependencies can be transpiled into go.mod just by running go mod init. After that go build succeeded with no problems. Resulting v1-like dependency for that project looks like:

module github.com/borteo/ermes

go 1.12

require (
	github.com/ahmdrz/goinsta v0.0.0-20171103100346-82b8eb0d9a3b
	github.com/dustin/go-humanize v1.0.0
	github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25
	github.com/joho/godotenv v0.0.0-20170328200154-325433c502d4
	github.com/nanobox-io/golang-scribble v0.0.0-20170327214430-da3a159a4622
	gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528
)

@ahmdrz
Copy link
Owner

ahmdrz commented Aug 1, 2019

@inliquid You help us a lot. ❤️
@falzm Do you confirm that it's working now?

@falzm
Copy link

falzm commented Aug 1, 2019

@ahmdrz yes I confirm it works – thank you for your help @inliquid!

@ahmdrz ahmdrz closed this as completed Aug 1, 2019
@ahmdrz ahmdrz mentioned this issue Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants