douhuan6065 2017-03-05 21:44
浏览 16
已采纳

如何在Go子目录中构建程序?

I have directory structure below. So server.go is in the main dir , and client.go in client sub directory (both are in package main). When I do ' go get -u ...' I have only server.go compiled under the name of MyGoProgram which is fine (executable in $GOPATH/bin)

MyGoProgram
client/client.go
server.go

How do I compile client.go ?

  • 写回答

1条回答 默认 最新

  • doutang1946 2017-03-05 22:14
    关注

    It's important to match your go directory to the structure described here: https://golang.org/doc/code.html

    so you should have:

    {$GOPATH}/bin
             /pkg
             /src/MyGoProgram/server.go
                             /client/client.go
    

    cd to {$GOPATH} and run the command go install ./src/MyGoProgram the executable will be created at /bin/MyGoProgram.exe

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

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办