dongzhuo1930
2017-01-12 08:39 阅读 48

在Linux Mint上获取OAuth2给我奇怪的错误

Attempting to follow along with https://jacobmartins.com/2016/02/29/getting-started-with-oauth2-in-go/

When I run go get golang.org/x/oauth2 nothing weird comes up, but when attempting to run the code using go run main.go

I get the following in my terminal:

# google.golang.org/grpc/credentials
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:58:32: error: reference to undefined field or method ‘GetCertificate’
   GetCertificate:           cfg.GetCertificate,
                                ^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:69:32: error: reference to undefined field or method ‘ClientSessionCache’
   ClientSessionCache:       cfg.ClientSessionCache,
                                ^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:72:32: error: reference to undefined field or method ‘CurvePreferences’
   CurvePreferences:         cfg.CurvePreferences,
                                ^
../../../google.golang.org/grpc/credentials/credentials_util_pre_go17.go:58:3: error: unknown field ‘GetCertificate’ in ‘tls.Config’
   GetCertificate:           cfg.GetCertificate,
   ^
# golang.org/x/net/http2/hpack
../../../golang.org/x/net/http2/hpack/huffman.go:14:20: error: reference to undefined identifier ‘sync.Pool’
 var bufPool = sync.Pool{
                    ^
../../../golang.org/x/net/http2/hpack/huffman.go:14:24: error: expected ‘;’ or newline after top level declaration
 var bufPool = sync.Pool{
                        ^
# golang.org/x/net/context/ctxhttp
../../../golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go:36:5: error: reference to undefined field or method ‘Cancel’
  req.Cancel = cancel
     ^
# golang.org/x/oauth2/jws
../../../golang.org/x/oauth2/jws/jws.go:75:17: error: reference to undefined identifier ‘base64.RawURLEncoding’
   return base64.RawURLEncoding.EncodeToString(b), nil
                 ^
../../../golang.org/x/oauth2/jws/jws.go:93:16: error: reference to undefined identifier ‘base64.RawURLEncoding’
  return base64.RawURLEncoding.EncodeToString(b), nil
                ^
../../../golang.org/x/oauth2/jws/jws.go:113:16: error: reference to undefined identifier ‘base64.RawURLEncoding’
  return base64.RawURLEncoding.EncodeToString(b), nil
                ^
../../../golang.org/x/oauth2/jws/jws.go:124:25: error: reference to undefined identifier ‘base64.RawURLEncoding’
  decoded, err := base64.RawURLEncoding.DecodeString(s[1])
                         ^
../../../golang.org/x/oauth2/jws/jws.go:151:41: error: reference to undefined identifier ‘base64.RawURLEncoding’
  return fmt.Sprintf("%s.%s", ss, base64.RawURLEncoding.EncodeToString(sig)), nil
                                         ^
../../../golang.org/x/oauth2/jws/jws.go:174:33: error: reference to undefined identifier ‘base64.RawURLEncoding’
  signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])

Go version is go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64

Running Linux Mint 17.3 Cinnamon

Anyone know what I'm doing wrong?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doujiao7483 doujiao7483 2017-01-13 21:07

    Looks like you are using go cgo installation. On Linux mint golang-go seems to be the distribution name.

    But I would suggest installing the latest version of go (or version go 1.5 atleast) as mentioned in the below link and try again.

    https://golang.org/doc/install

    Remove your current installation before proceeding with the golang-go installation.

    点赞 评论 复制链接分享

相关推荐