Code Monkey home page Code Monkey logo

Comments (5)

jkawamoto avatar jkawamoto commented on July 27, 2024 1

I'm sorry I used the wrong repository name. This worked for me:

$ gofmt -w -r '"github.com/dgrijalva/jwt-go" -> "github.com/golang-jwt/jwt"' .
$ go get github.com/golang-jwt/jwt

from jwt.

mfridman avatar mfridman commented on July 27, 2024 1

@turkenh @jkawamoto We just landed module support, so I'd suggest dropping the replace if you're having troubles with transitive dependencies and instead importing this package as "github.com/golang-jwt/jwt/v4".

Closing this issue. Feel free to continue commenting and/or create a new issue.

from jwt.

oxisto avatar oxisto commented on July 27, 2024

I had a quick look into your PR and I fear that you are stuck in the middle for now. The replace route only works of you keep the original import path. Replacing the import path will not replace transitive imports.

My best guess would be to switch back to the old dgrijalva import path and use replace. Then once, your transitive dependency also switches to the new import path, remove the replace and switch the import path. Not really a good solution, but it is probably the "safest".

We probably should update the migration guide to reflect that you could run into this kind of problem with other transitive dependencies.

from jwt.

jkawamoto avatar jkawamoto commented on July 27, 2024

Same here. I only run go mod edit and go mod tidy without editing any code but get this error:

$ go mod edit -replace github.com/dgrijalva/jwt-go=github.com/golang-jwt/[email protected]+incompatible
$ go mod tidy
go: finding module for package github.com/golang-jwt/jwt/test
go: finding module for package github.com/golang-jwt/jwt
go: finding module for package github.com/golang-jwt/jwt/request
go: downloading github.com/golang-jwt/jwt v1.0.2
go: found github.com/golang-jwt/jwt in github.com/golang-jwt/jwt v3.2.1+incompatible
go: found github.com/golang-jwt/jwt/request in github.com/golang-jwt/jwt v3.2.1+incompatible
go: found github.com/golang-jwt/jwt/test in github.com/golang-jwt/jwt v3.2.1+incompatible
go: github.com/golang-jwt/[email protected]+incompatible used for two different module paths (github.com/dgrijalva/jwt-go and github.com/golang-jwt/jwt)

I'm not sure why it tries to download v1.0.2 (go: downloading github.com/golang-jwt/jwt v1.0.2).

I also try to replace import paths in my code with gofmt -w -r '"github.com/dgrijalva/jwt-go" -> "github.com/golang-jwt/jwt-go"' . then get this error:

$ gofmt -w -r '"github.com/dgrijalva/jwt-go" -> "github.com/golang-jwt/jwt-go"' .
$ go mod download github.com/golang-jwt/jwt-go
go mod download: module github.com/golang-jwt/jwt-go: not a known dependency

go mod download github.com/golang-jwt/[email protected]+incompatible doesn't return any errors but it looks like it doesn't work:

$ gofmt -w -r '"github.com/dgrijalva/jwt-go" -> "github.com/golang-jwt/jwt-go"' .
$ go mod download github.com/golang-jwt/[email protected]+incompatible
$ go test ./... -v
main.go:25:2: no required module provides package github.com/golang-jwt/jwt-go; to add it:
        go get github.com/golang-jwt/jwt-go

I'm wondering if #30 could help. Btw, I'm using Go 1.16.6:

$ go version
go version go1.16.6 darwin/amd64

from jwt.

mfridman avatar mfridman commented on July 27, 2024

I had a quick look into your PR and I fear that you are stuck in the middle for now. The replace route only works of you keep the original import path. Replacing the import path will not replace transitive imports.

My best guess would be to switch back to the old dgrijalva import path and use replace. Then once, your transitive dependency also switches to the new import path, remove the replace and switch the import path. Not really a good solution, but it is probably the "safest".

We probably should update the migration guide to reflect that you could run into this kind of problem with other transitive dependencies.

Ye, I don't know if there is a better solution here when using the replace directive. I believe this is related to golang/go#26904

I haven't been keeping a close eye on modules, but I think there is some work by @bcmills and the Go team to address such issues in 1.17 and/or 1.18

from jwt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.