dongshuzui0335 2016-07-31 00:12
浏览 72
已采纳

在GitHub中设置golang以使用Python

I have a GitHub repo with some python code and some text files. However, I want to add some Golang code to my project.

So basically my issue is that I'm confused on where to set my GOPATH so I can work with Go source files in the same place that I work on python files. Do I set my GOPATH to my repo path, then setup the \src\github.com\user\ directory and put my Go code there? Do I put Grandzam where user is, or leave it alone because someone else is working with me on the repo?

https://golang.org/doc/install Test your installation is what I am confused about.

  • 写回答

1条回答 默认 最新

  • doutao1939 2016-07-31 00:57
    关注

    I would recommend setting up an environment consistent with the recommendations in the "Organizing your code" section of the language documentation.

    First, choose a top level directory (I tend to use ~/devel), and set the value of your GOPATH environment var to that location, and add the GOPATH/bin dir to your path. Put it in your the appropriate session startup file (~/.bash_profile or similar). In my case, I would put these lines in that file:

    export GOPATH=$HOME/devel
    export PATH=$GOPATH/bin:$PATH
    

    Quoting from the documentation:

    To give you an idea of how a workspace looks in practice, here's an example:

    bin/
        hello                          # command executable
        outyet                         # command executable
    pkg/
        linux_amd64/
            github.com/golang/example/
                stringutil.a           # package object
    src/
        github.com/golang/example/
            .git/                      # Git repository metadata
        hello/
            hello.go               # command source
        outyet/
            main.go                # command source
            main_test.go           # test source
        stringutil/
            reverse.go             # package source
            reverse_test.go        # test source
        golang.org/x/image/
            .git/                      # Git repository metadata
        bmp/
            reader.go              # package source
            writer.go              # package source
        ... (many more repositories and packages omitted) ...
    

    Next, clone your git repo into the appropriate path under the $GOPATH/src tree. In my case it would be $GOPATH/src/github.com/user/repo.

    Now you should be all set to work on both go and python code without much trouble.

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

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题