dongzhuo1930 2017-01-12 08:39
浏览 49
已采纳

在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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码