0

I am new to go. I am trying to set up a secure webserver using go and jwt, but I cannot get this to compile:

mw := jwtmiddleware.New(jwtmiddleware.Options{
        ValidationKeyGetter: func (token *jwt.Token) (interface{}, error) {
            return mySigningKey, nil
        },
        SigningMethod: jwt.SigningMethodHS256,
    })

but I only get the following error (from the compiler and the analyzer):

cannot use func literal (type func(*"webserver/vendor/github.com/dgrijalva/jwt-go".Token) (interface {}, error)) as type "github.com/dgrijalva/jwt-go".Keyfunc in field value   

I have tried making it a separate named func but that didn't help. The jwt library shows

type Keyfunc func(*Token) (interface{}, error)

so, it should match the signature. The code is the same in several online examples including auth0.com.

I have had success running simpler go programs, including serving a simple web page, so the compiler is working correctly.

Running on ubuntu 18.04 with the newest stable version of go and packages (downloaded and installed a few days ago). Thanks

4

1 回答 1

0

似乎该软件包不在 vendor/github.com 中。我做了以下事情:

cp -R ../github.com/auth0 vendor/github.com/auth0

现在可以编译了。

于 2018-10-07T06:27:46.660 回答