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 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致