Go and devops are both new things for me. I'd like to setup a CI that tests and builds my module, then stores artifacts for download. In addition it'd be good to cache dependencies for next builds.
I don't get how to do it using subdirectory for the go product. I want my git repository to look like that:
+ repository_root/
+ go/
- go.mod
- go.sum
+ hello/
- main.go
+ cpp/
+ python/
+ .circleci/
go.mod
module github.com/{USER}/{REPOSITORY_ROOT}/go
go 1.14
Of course {USER} is replace with my github user name and {REPOSITORY_ROOT} is the repo name.
For now I have a following config.yml that doesn't work.
version: 2
jobs:
build:
working_directory: ~/project/go
docker:
- image: circleci/golang:1.9
steps:
- checkout:
path: ~/project/
- run: mkdir bin
- run: go get -v -t -d ./...
- run: go test -v ./...
- run: go build -o bin/hello.exe github.com/{USER}/{REPOSITORY_ROOT}/go/hello
- store_artifacts:
path: bin/
destination: hello-app
Error on build command:
#!/bin/bash -eo pipefail
go build -o ./bin/hello.exe github.com/{USER}/{REPO_ROOT}/go/hello
can't load package: package github.com/{USER}/{REPO_ROOT}/go/hello: cannot find package "github.com/{USER}/{REPO_ROOT}/go/hello" in any of:
/usr/local/go/src/github.com/{USER}/{REPO_ROOT}/go/hello (from $GOROOT)
/go/src/github.com/{USER}/{REPO_ROOT}/go/hello (from $GOPATH)
Exited with code exit status 1
CircleCI received exit code 1
I know that the module is outside of GOPATH
but I have the same setup on my local machine and the same build command works just fine.