version: 2.1
jobs:
  lint:
    docker:
      - image: golang:1.11
    environment:
      GO111MODULE: 'on'
    working_directory: /go/src/github.com/y0ssar1an/q
    steps:
      - checkout
      - run: go install -mod vendor github.com/y0ssar1an/q/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
      - run: golangci-lint run
  test:
    docker:
      - image: golang:1.11
    environment:
      GO111MODULE: 'on'
    working_directory: /go/src/github.com/y0ssar1an/q
    steps:
      - checkout
      - restore_cache:
          keys:
            - pkg-cache
      - run: go test -mod vendor -v -race ./...
      - save_cache: # cache the /go/pkg directory
          key: pkg-cache
          paths:
            - '/go/pkg'

workflows:
  build_and_test:
    jobs:
      - lint
      - test

version: 2.1

executors:
  go-container:
    docker:
      - image: golang:1.11
    environment:
      GO111MODULE: 'on'
    working_directory: /go/src/github.com/y0ssar1an/q

jobs:
  lint:
    executor:
      name: go-container
    steps:
      - checkout
      - restore_cache:
          keys:
            - go-pkgs-{{ checksum "go.sum" }}
      - run: go install -mod vendor github.com/y0ssar1an/q/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
      - run: golangci-lint run
  test:
    executor:
      name: go-container
    steps:
      - checkout
      - restore_cache:
          keys:
            - go-pkgs-{{ checksum "go.sum" }}
      - run: go test -mod vendor -v -race ./...
      - save_cache:  # cache the /go/pkg directory
          key: go-pkgs-{{ checksum "go.sum" }}
          paths:
            - '/go/pkg'

workflows:
  build_and_test:
    jobs:
      - lint
      - test

Improve caching of Go pkgs on CircleCI
Improve caching of Go pkgs on CircleCI
