ahmdrz / goinsta

Unofficial Instagram API written in Golang
MIT License
895 stars 247 forks source link

Problem downloading package into project using go modules #193

Closed g5becks closed 5 years ago

g5becks commented 5 years ago

I am attempting to download this package into a project that is a go module outside of GOPATH and I keep getting the following error,

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 latest
go: gopkg.in/ahmdrz/goinsta.v2@v2.0.0-20180703233155-8a4b1078ad1b: go.mod has non-....v2 module path "github.com/ahmdrz/goinsta" at revision 8a4b1078ad1b

if I download the package without it being part of a module there's no issues, any clue as to what's going wrong here?

zaddok commented 5 years ago

Yep, I just stumbled across the same problem. This package is unusable with the go.mod file in it.

〖instagram-go〗go get github.com/ahmdrz/goinsta
go: finding github.com/ahmdrz/goinsta latest
go: github.com/ahmdrz/goinsta@v0.0.0-20181121053846-aa250bb4ac58: parsing go.mod: unexpected module path "github.com/ahmdrz/goinsta.v2"
go: error loading module requirements

Furthermore, the module file claims to be v2, but go get with v2 fails as well:

〖instagram-go〗go get github.com/ahmdrz/goinsta@v2
go get github.com/ahmdrz/goinsta@v2: no matching versions for query "v2"
zaddok commented 5 years ago

To work around this issue, I fixed it in a temporary fork, you can do:

go get github.com/zaddok/goinsta@v3.0.1 And then alter your import to import:

"github.com/zaddok/goinsta/v3" I won't maintain this fork, its just a workaround to use until this main repo gets fixed.

g5becks commented 5 years ago

@zaddok still gettiing errors.


go: finding github.com/zaddok/goinsta v0.0.0-20190115003453-316a7ae6d418
go: github.com/zaddok/goinsta@v0.0.0-20190115003453-316a7ae6d418: go.mod has post-v0 module path "github.com/zaddok/goinsta/v3" at revision 316a7ae6d418
go: error loading module requirements
zaddok commented 5 years ago

I worked out why, I fixed it, and tested it, and now this works:

〖tmp〗mkdir test5
〖tmp〗cd test5
〖test5〗go mod init test5
go: creating new go.mod: module test5
〖test5〗go get github.com/zaddok/goinsta/v4

Hopefully it can get fixed in the main branch soon. It turns out, when you do the tag, (i.e. git tag v3.0.0 you must already have updated and committed the go.mod module name to contain the \v3. If you tag first, and update go.mod second, the whole thing won't work.

g5becks commented 5 years ago

@zaddok Great, I hope this gets fixed soon.

g5becks commented 5 years ago

@ahmdrz any plans on fixing this? I can fix it and create a pull request if need be. Although it's only one line.

ahmdrz commented 5 years ago

Hi @Gee5ive. It's open for all of GitHub users to be a goinsta contributor. Let's make a PR and I will merge it.

zaddok commented 5 years ago

The reason I didn’t do a patch request is because fixing the issue appears to require both an update to the go.mod and also fixing how the project is tagged. (That’s why I bumped the major version number in my fork)

I don’t think editing the go.mod alone will fix it, the patch here doesn’t bump from v2 to v3

g5becks commented 5 years ago

@zaddok what's the reason the tag has to be updated? Just to test things out, I forked the repo and only updated the go.mod then ran go get github.com/Gee5ive/goinsta/v4 and it worked fine on my end without adding any tags.

In any case, I'm not going to open a request, as there's really no way for me to accurately test if it will work once the upstream is updated. I don't think a contributor should be the one to update anything having to do with versioning. Hopefully, @ahmdrz can get around to fixing this when there is time.

krylovsk commented 5 years ago

@Gee5ive Go modules require semver tags, see #203 and go modules documentation

g5becks commented 5 years ago

@krylovsk Thanks, I learned something new today. Was'nt familiar with the replace directive.

ahmdrz commented 5 years ago

Does everybody accept #203? I'm not familiar with .mod file.

zaddok commented 5 years ago

As you can see, I am still learning myself. I had to fix the .mod file, and add a semver tag to make it work. I assume if you do that it will work.

I suspect that the problem might be that you can’t start adding v2 into a project until you are using semver tags. (Once you add the v2, certain expectations are imposed)

(I bumped the major version to v3, I’m not sure if that was necessary though. I only did that as I was in a hurry to get it to work)

PS: aside from this particular issue your Instagram library is great. Thanks!

g5becks commented 5 years ago

@ahmdrz any updates on merging ahmdrz/goinsta/#203 ?