dou6495 2014-08-12 19:27
浏览 153
已采纳

Go无法检测到`sync`软件包

I get error: reference to undefined identifier ‘sync.Pool’ message and this is working in Playground. What should I do?

package main

import (
  "fmt"
  "sync"
)

func main() {
  var wg sync.Pool
  fmt.Println(wg)
}
  • 写回答

2条回答 默认 最新

  • dsdf64562672 2014-08-12 19:40
    关注

    If you installed go from source, check what $GOROOT et ^$GOROOT_FINAL refer to: if they differ, you need to reset your GOROOT to GOROOT_FINAL.

    The value assumed by installed binaries and scripts when $GOROOT is not set explicitly.
    It defaults to the value of $GOROOT.

    If you want to build the Go tree in one location but move it elsewhere after the build, set $GOROOT_FINAL to the eventual location.


    From the comments, the OP mentions:

    go version prints out

    go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64 
    

    And $GOROOT/pkg/linux_amd64/sync.a does exist.

    I recommended to make sure $PATH includes $GOROOT/bin JimB added:

    to be more specific, make sure your $PATH contains $GOROOT/bin for the correct GOROOT. I think you have two installations making this more confusing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求会做山景bo1048b2程序的 直播声卡用
  • ¥15 51单片机与数码管实现电子琴
  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错