import paths issue with SignedAndEncrypted()
I'm trying to use the SignedAndEncrypted() / ParseSignedAndEncrypted() workflow to implement JWE and I ran into problems with the import path in this repo:
cannot use sig (type "bitbucket.eng.zebrium.com/zsw/zwsd/vendor/github.com/square/go-jose".Signer) as type "bitbucket.eng.zebrium.com/zsw/zwsd/vendor/gopkg.in/square/go-jose.v2".Signer in argument to jwt.SignedAndEncrypted
I resolved the problem by using the gopkg vertion:
import (
jose "gopkg.in/square/go-jose.v2"
//"github.com/square/go-jose"
"github.com/square/go-jose/jwt"
)
I'm concerned that this code may be out-of-date. Is there a better solution? Is there a different workflow for JWE that I should be using instead?
Using the gopkg.in import path is the correct solution.
The import path determines which version (branch) is imported. The stable version right now is v2, for which the import path is the gopkg.in one. Make sure to use this import path consistently for all imports (including of sub-packages).
See also: https://github.com/square/go-jose#versions https://github.com/golang/go/wiki/Modules