dongluojiao6322 2015-02-13 19:46
浏览 100

安装go1.4.1.darwin-amd64-osx10.8.pkg后如何在MAC上设置GOPATH

I have run go1.4.1.darwin-amd64-osx10.8.pkg to install go on my MAC. It install go in /usr/local/go/bin/go.

Can you tell me what should my GOPATH set to? I tried '/usr/local/go' and '/usr/local/go/bin/go'. But both does not seem to be the right path.

Thank you.

  • 写回答

2条回答 默认 最新

  • douzhanbai9526 2015-04-05 01:12
    关注

    GOPATH is an environmental variable used to define the location of your workplace directory. It's used by the Go tools for various reasons.

    For example:

    go get -u github.com/nsf/gocode

    • will download the source code and place it at $GOPATH/src/github.com/nsfs/gocode
    • Compile that source code and place the binary at $GOPATH/bin
    • Place symbol and package information at $GOPATH/pkg/architecture/github.com/nsfs

    The path is also used in other tools:

    • go build github.com/nsf/gocode
    • go install github.com/nsfs/gocode

    github.com/nsfs/gocode in the above commands is resolved automatically to $GOPATH/src/github.com/nsfs/gocode and thus you can run these commands without actually being in your workplace (the point of $GOPATH)

    The $GOPATH location for your workplace directory can be put anywhere on your machine, but it must minimally have 3 folders (because go get and other tools need these folders).

    1. bin
    2. pkg
    3. src

    This environmental variable can be set like any other environmental variable. If you're using go from the Terminal.app, you can set it by opening the file:

    vi ~/.bashrc

    and then setting it

    export GOPATH=~/goworkplace

    ~/goworkplace is a location to the workplace directory with those 3 folders. It can be anywhere on your system, such as, ~/Development/goworkplace, ~/Desktop/goworkplace, as long as it has those 3 folders

    For information, take a look at this: https://golang.org/doc/code.html

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)