Go coverage example
Switch branches/tags
Nothing to show
Clone or download
Latest commit b856387 Apr 26, 2018


Codecov Go Example

This repository serves as an example on how to use Codecov Global for Go.

Note: use -covermode=atomic or -covermode=count to show how many times a statement was executed.

Travis CI

Add to your .travis.yml file.

language: go

  - 1.8.x
  - tip

  - go get -t -v ./...

  - go test -race -coverprofile=coverage.txt -covermode=atomic

  - bash <(curl -s https://codecov.io/bash)

Private Repos

Set CODECOV_TOKEN in your environment variables.

Add to your .travis.yml file.

  - bash <(curl -s https://codecov.io/bash) -t uuid-repo-token

Or you can set the environment variable CODECOV_TOKEN=uuid-repo-token and remove the -t flag

Caveat: Multiple files

If you see this cannot use test profile flag with multiple packages then use this shell template to execute your tests and store coverage output

#!/usr/bin/env bash

set -e
echo "" > coverage.txt

for d in $(go list ./... | grep -v vendor); do
    go test -race -coverprofile=profile.out -covermode=atomic $d
    if [ -f profile.out ]; then
        cat profile.out >> coverage.txt
        rm profile.out

Then run this file as your test (ex. ./test.sh)

Reference http://stackoverflow.com/a/21142256/2055281

View source and learn more about Codecov Global Uploader

We are happy to help if you have any questions. Please contact email our Support at support@codecov.io