Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Make compatible with go modules #259

Closed
wants to merge 2 commits into from
Closed

Conversation

vladimiroff
Copy link

As stated in golang/go#24384:

vgo only allows v2+ when there is a go.mod file so please tell the package maintainer/owner to make the package vgo compatible.

Thus it's impossible to add anything after version 1.0.2 of this package as dependency in project built with vgo.

As vgo requires from version v2.0.0 there's supposed to be a `/vX` in
the module name. For users this means that they have to import jwt as
`github.com/dgrijalva/jwt-go/v3`. Sub-package's name go after the
version (e.g `github.com/dgrijalva/jwt-go/v3/request`).

See: https://blog.golang.org/versioning-proposal

At some point (CL: 105215) vgo started supporting and preferring
unquoted strings in mod files. This change unquotes the module name.
@vladimiroff
Copy link
Author

Just updated this PR as described in the latest commit.

In order to test the changes before merging, I've renamed the module name in the master branch of my fork and tagged a v3.2.1.

Then created a new package foo in $GOPATH/src/github.com/vladimiroff/foo from where to import jwt with foo.go:

package foo

import (
	jwt "github.com/vladimiroff/jwt-go/v3"
	"github.com/vladimiroff/jwt-go/v3/request"
)

var (
	extractor request.Extractor
	claims    jwt.StandardClaims
)

Then just touched a go.mod file and ran vgo build -v and observe that latest tag with go.mod file and proper module name is chosen:

--> touch go.mod                                                                                                                       kiril@widdle:/home/kiril/go/src/github.com/vladimiroff/foo  [11:44:14]
--> vgo build -v                                                                                                                       kiril@widdle:/home/kiril/go/src/github.com/vladimiroff/foo  [11:44:15]
vgo: resolving import "github.com/vladimiroff/jwt-go/v3"
vgo: finding github.com/vladimiroff/jwt-go/v3 (latest)
vgo: adding github.com/vladimiroff/jwt-go/v3 v3.2.1
--> cat go.mod                                                                                                                         kiril@widdle:/home/kiril/go/src/github.com/vladimiroff/foo  [11:44:24]
module github.com/vladimiroff/foo

require github.com/vladimiroff/jwt-go/v3 v3.2.1
--> 

@vladimiroff vladimiroff changed the title Make compatible with vgo Make compatible with go modules Jul 24, 2018
@mfridman
Copy link

@vladimiroff Just in case this was still an issue for you, go1.11beta2 added the meta flag +incompatible

if a source code repository has a v2.0.0 or later tag for a file tree with no go.mod, the version is considered to be part of the v1 module's available versions and is given an +incompatible suffix when converted to a module version, as in v2.0.0+incompatible

There was another good discussion here golang/go#25967 (comment)

@jesusvazquez jesusvazquez mentioned this pull request Apr 7, 2019
@vladimiroff
Copy link
Author

#301 solves the issue and makes this PR obsolete.

@vladimiroff vladimiroff closed this Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants