Skip to content

Instantly share code, notes, and snippets.

@StevenACoffman
Created December 8, 2019 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StevenACoffman/47ca8bab42129a3a9c215304d3b4133a to your computer and use it in GitHub Desktop.
Save StevenACoffman/47ca8bab42129a3a9c215304d3b4133a to your computer and use it in GitHub Desktop.
Locking Go Tools

If you've ever dealt with a team where different people had different versions of linters installed, you'll quickly realize that you should also lock your tools.

Before Go 1.13

Before Go 1.13 the recommended solution was to use tools.go file like this:

// +build tools

package tools

import (
    _ "golang.org/x/lint/golint"
)

This way, go mod can pick the tool up and lock its version as well.

Go 1.13+

Now with go 1.13.x go mod tidy adds such dependencies to the module's go.mod and go.sum files.

If your dependencies on build tools are mixed with your run time dependencies

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