Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
September 29, 2022 13:38
January 26, 2020 12:39
August 16, 2020 17:22
February 1, 2020 12:16
January 26, 2020 11:34
January 23, 2021 23:25
January 20, 2021 13:09
January 26, 2020 10:33
September 29, 2022 13:38
November 7, 2023 06:50
August 25, 2022 06:41
August 25, 2022 06:40
August 25, 2022 06:40
September 18, 2021 14:39
September 18, 2021 14:39
August 16, 2020 17:06
September 18, 2021 14:40
August 16, 2020 17:06
August 16, 2020 17:06
August 16, 2020 17:06


Build Status Release Coverage Status Go Report Card Godocs

The forgotten go tool that executes and caches binaries included in go.mod files. This makes it easy to version cli tools in your projects such as golangci-lint and ginkgo that are versioned locked to what you specify in go.mod. Binaries are cached by go version and package version.


  # Run a linter
  gomodrun golangci-lint run

  # Convert a JSON object to a Go struct, properly passing in stdin.
  echo example.json | gomodrun gojson > example.go

  # Specifiy alternative root directory containing a go.mod and tools file.
  gomodrun -r ./alternative-tools-dir golangci-lint run

  # Clean your .gomodrun folder of unused binaries.
  gomodrun --tidy



go get -u


gomodrun works by using a tools.go (or any other name) file that sits in the root of your project that contains all the CLI dependencies you want bundled in to your go.mod. Note the // +build tools at the top of the file is required, and allows you to name your tools file anything you like.


// +build tools

package myapp

import (
	_ ""
	_ ""

Run go build tools.go to add the dependencies to your go.mod. The build is expected to fail.


You can run your tools by prefixing gomodrun. A binary will be built and cached in .gomodrun in the root of your project, allowing all runs after the first to be nice and fast.

  gomodrun golangci-lint run


You can also use gomodrun as a library.

package main

import (


func main() {
	exitCode, err := gomodrun.Run("golangci-lint", []string{"run"}, &gomodrun.Options{
		Stdin:   os.Stdin,
		Stdout:  os.Stdout,
		Stderr:  os.Stderr,
		Env:     os.Environ(),
		PkgRoot: "",