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

Problem with import path for go-resty and go1.11 modules #1063

Closed
pierredavidbelanger opened this issue Sep 29, 2018 · 14 comments
Closed

Problem with import path for go-resty and go1.11 modules #1063

pierredavidbelanger opened this issue Sep 29, 2018 · 14 comments

Comments

@pierredavidbelanger
Copy link
Contributor

In a toy project, I am trying to use the Hydra Go SDK.

I am using go1.11 with the new modules feature.

I am facing a problem when building because Go expect the lib github.com/go-resty/resty to be imported using the package gopkg.in/resty.v1 (see its go-mod's module instruction):

go: github.com/go-resty/resty@v1.9.1: parsing go.mod: unexpected module path "gopkg.in/resty.v1"
go: error loading module requirements

And the root cause of this, is this line here where you import github.com/go-resty/resty.

I see that this file seems NOT to be generated by swagger-codegen ?

Can I just send a PR to use the right import path for go-resty in api_client.go ?

@laibulle
Copy link

laibulle commented Sep 30, 2018

As a temporary workaround, I am running

sudo sed -i -e 's/"github.com\/go-resty\/resty"/resty "gopkg.in\/resty.v1"/g' \
    `$GOPATH/pkg/mod/github.com/ory/hydra@v1.0.0-beta.9/sdk/go/hydra/swagger/api_client.go`

@aeneasr
Copy link
Member

aeneasr commented Oct 1, 2018

The file is indeed generated by swagger but we have to revert it because the underlying code template does not support certain features we needed before. Open to change the import path as long as it doesn't break stuff.

@pierredavidbelanger
Copy link
Contributor Author

@laibulle this is also exactly what I have done to workaround the problem. This is why I know the fix works.

@aeneasr If this file is indeed generated, maybe I should check with swagger-codegen then, we dont want to manually edit a file now and have the same problem appear later when we finally use the generated version.

@aeneasr
Copy link
Member

aeneasr commented Oct 1, 2018

We're manually updating it anyways because of a patch I had to add. So it's fine to hotfix this as a new commit. swagger-codegen is kinda f*ed anyways because they introduced a new version 2.4 (we're on 2.2 I think) which has a completely different template which is even worse than the one right now. version 3.0 is in rc I think but there are no templates yet, so even if you make a PR or issue it's unlikely that it will be fixed.

@aeneasr
Copy link
Member

aeneasr commented Oct 8, 2018

This is resolved

@lanshipeng
Copy link

@pierredavidbelanger , need your help. error on loading resty package with go modules. when i use go mod tidy or go build . it's not succeed.
image

@pierredavidbelanger
Copy link
Contributor Author

@lanshipeng I am sorry, I did not contributed to this project lately, you should try the chat and see with them if you should open a new issue for this.

But , as a workaround, try to not let go choose the version for you (it will maybe not choose the right one), and target a specific version instead, one that we know this bug is fixed in.

for example, this is the last commit in the master branch:

go get github.com/ory/hydra@55654c084cc24a49d333e62773295cbf8bf5b31d

@pereslava
Copy link

pereslava commented Apr 1, 2019

Still having the issue on brand new project. Bellow the steps:

mkdir go-sdk-test
cd go-sdk-test
go mod init testhydra

then in main.go:

package main

import (
	"fmt"

	"github.com/ory/hydra/sdk/go/hydra"
)

func main() {
	fmt.Println("Hi")
	_, _ := hydra.NewSDK(&hydra.Configuration{
		AdminURL: "https://hydra.localhost:4445",
	})

}

then

go mod tidy

go: finding github.com/ory/hydra/sdk/go/hydra latest
go: finding github.com/ory/hydra/sdk/go latest
go: finding github.com/ory/hydra/sdk latest
go: finding github.com/stretchr/testify/assert latest
go: finding golang.org/x/oauth2 latest
go: finding golang.org/x/oauth2/clientcredentials latest
go: github.com/go-resty/resty@v1.12.0: parsing go.mod: unexpected module path "gopkg.in/resty.v1"
go: error loading module requirements

go version go1.12 linux/amd64

@pierredavidbelanger
Copy link
Contributor Author

Pin Hydra to a specific version:

go get github.com/ory/hydra@v1.0.0-rc.6+oryOS.10

@pereslava
Copy link

@pierredavidbelanger
Thanks.
I pinned it in mo go.mod file:
require github.com/ory/hydra v1.0.0-rc.6+oryOS.10

It solver the problem, and it should work properly in the build scripts without go get ...

@pereslava
Copy link

Not working after new release:

$ go get github.com/ory/hydra@v1.0.0-rc.6+oryOS.10
go: finding github.com/ory/hydra v1.0.0-rc.6
go get github.com/ory/hydra@v1.0.0-rc.6+oryOS.10: unknown revision v1.0.0-rc.6
$ go get github.com/ory/hydra@v1.0.0-rc.8+oryOS.10
go: finding github.com/ory/hydra v1.0.0-rc.8
go get github.com/ory/hydra@v1.0.0-rc.8+oryOS.10: unknown revision v1.0.0-rc.8

@aeneasr
Copy link
Member

aeneasr commented Apr 5, 2019

That's a diffrerent issue. You must use go get github.com/ory/hydra@v1.0.0 or go get github.com/ory/hydra@v1.0.0-rc.8

@aeneasr
Copy link
Member

aeneasr commented Apr 5, 2019

Hm, seems like go mod has issues with resolving tags like rc.8. I'll investigate. Also go-resty is freaking annoying and we'll move to go-swagger generated code instead.

@aeneasr aeneasr reopened this Apr 5, 2019
@aeneasr
Copy link
Member

aeneasr commented Apr 11, 2019

This should be fixed now that we're no longer using swagger-codegen but go-swagger

@aeneasr aeneasr closed this as completed Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants