Skip to content

Instantly share code, notes, and snippets.

@azihsoyn
Created March 23, 2018 12:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save azihsoyn/7f307e39e4a493c24235367e711e3725 to your computer and use it in GitHub Desktop.
Save azihsoyn/7f307e39e4a493c24235367e711e3725 to your computer and use it in GitHub Desktop.
example circleci 2.0 with go 1.10
version: 2
jobs:
build:
working_directory: /go/src/github.com/your_company/your_app
docker:
- image: circleci/golang:1.10.0
environment:
- GOCACHE: "/tmp/go/cache"
- DEP_VERSION: 0.4.1
steps:
- run: git config --global url.ssh://git@github.com/your_company.insteadOf https://github.com/your_company
- checkout
- restore_cache:
key: gopkg-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
paths:
- /go/src/github.com/your_company/your_app/vendor
- run:
name: download-libraries
command: |
if [ ! -d /go/src/github.com/your_company/your_app/vendor ]; then
curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o /go/bin/dep
chmod +x /go/bin/dep
/go/bin/dep ensure
fi
- save_cache:
key: gopkg-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
paths:
- /go/src/github.com/your_company/your_app/vendor
- restore_cache:
keys:
- build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
paths:
- /tmp/go/cache
- run:
name: test
command: |
mkdir -p $GOCACHE
go build -v
go test -p 6 -race ./...
- save_cache:
key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_BUILD_NUM }}
paths:
- /tmp/go/cache
@alexGuerraDev
Copy link

Thank's friend, it served me a lot.

@HolimaX
Copy link

HolimaX commented Aug 20, 2019

Well, it still does not really help me... https://stackoverflow.com/questions/57545628/local-build-successful-while-circleci-build-failing .

Oddly enough, if the imports are made 4 levels up (like import "../../../../<github.com/cyz/abc>"), go build suddenly works. I wonder what is screwed up in those Images, made by CircleCI guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment