language: go

os:
  - linux
  - osx

install:
  # Use gofmt from Go 1.9 for the pre-build check on all builds
  - if [ "$TRAVIS_OS_NAME" = "osx" ]; then wget -O go.tar.gz https://storage.googleapis.com/golang/go1.9.darwin-amd64.tar.gz; else wget -O go.tar.gz https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz; fi
  - tar -C /tmp -xvf go.tar.gz go/bin/gofmt
  - rm go.tar.gz

before_script:
  - /tmp/go/bin/gofmt -w .

  # If `go generate` or `gofmt` yielded any changes,
  # this will fail with an error message like "too many arguments"
  # or "M: binary operator expected" and show the diff.
  - git diff
  - git add .
  - git diff-index --cached --exit-code HEAD

go:
  - 1.7
  - 1.8
  - 1.9
  - tip

matrix:
    include:
        - os: linux
          go: 1.6

script:
  - echo $TRAVIS_GO_VERSION
  - if [ "$TRAVIS_GO_VERSION" == "1.6" ] || [ "$TRAVIS_GO_VERSION" == "1.7" ] || [ "$TRAVIS_GO_VERSION" == "1.8" ]; then go list ./... | grep -v vendor | xargs go test -race -v -timeout 60s; else go test -race -v -timeout 60s ./...; fi
