duanqinqian5299 2019-07-27 23:26
浏览 19

在项目中构建所有go软件包

I am making a Go project containing a few packages. Those are data structures (and there will be algorithms as well). My project root looks like this:

C:.
├───array
├───binary_tree
├───heap
└───list

The thing is, I want to add like a CI. So I would have a job checking if all packages build and if all tests pass.

Unfortunately, I can't run go build on project root. I have to pass whole path to it. I mean I could write a script which calls go build X/Y/foo and then go build X/Y/bar, but the CI on GitLab (docker image) won't have those paths, it will just git clone my repo and that's it (cuz I cannot run it on a relative path from project root, but a relative path from GOPATH, so like github.com/dabljues/project_name/array). And what about the test?

So the question there would be: Can I somehow run go build and go test for all the packages in the Go project? (located in separate folders)

  • 写回答

1条回答 默认 最新

  • duanjie6912 2019-07-27 23:40
    关注

    Use a Makefile. Define the targets and instruction to compile them.

    For example define the following in a Makefile

    build:
        go build -o bin/main main.go
    
    run:
        go run main.go
    

    To run just invoke : make build

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度