using-go-tool-directive

Manage Go development tools using the Go 1.24+ tool directive in go.mod.

Updated Mar 7, 2026
One-click install
npx skills add https://github.com/mazrean/agent-skills --skill using-go-tool-directive
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-go-tool-directive
Source: https://github.com/mazrean/agent-skills/tree/main/skills/using-go-tool-directive
Command: npx skills add https://github.com/mazrean/agent-skills --skill using-go-tool-directive

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the management of project-specific Go development tools, ensuring consistent versions across your team and CI/CD pipelines by leveraging the Go 1.24+ tool directive.

Core Features & Use Cases

  • Tool Management: Add, update, and remove linters, generators, and dev tools directly within your go.mod.
  • Reproducible Builds: Guarantees that all developers and CI environments use the exact same tool versions.
  • Use Case: When adding a new linter like golangci-lint to your project, use this Skill to declare it in go.mod, making it available for all team members and automated checks without manual installation steps.

Quick Start

Add the stringer tool to your project by running the command: go get -tool golang.org/x/tools/cmd/stringer@latest.

Frequently Asked Questions about using-go-tool-directive

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage Go development tools using the go.mod tool directive?

You can manage Go development tools by adding them directly to go.mod using the `tool` directive with commands like `go get -tool`, ensuring consistent tool versions across your team and CI pipelines.

What Go version is required to use the tool directive for linters and generators?

The `tool` directive for managing linters, generators, and dev tools requires Go 1.24 or later. You must upgrade your Go environment to leverage this native go.mod management feature.

How do I migrate from the tools.go pattern to the go.mod tool directive?

To migrate from the tools.go pattern, add your existing development tools to go.mod using the `tool` directive and remove the legacy tools.go file to ensure reproducible builds across environments.

How do I add a linter like golangci-lint to go.mod for reproducible builds?

Add a linter to your project by running `go get -tool` followed by the linter's package path. This declares the tool in go.mod, making it available for all team members and automated checks without manual installation.

Can I integrate go.mod managed tools with go:generate commands?

Yes, tools declared in go.mod using the `tool` directive can be integrated with `go:generate` commands, allowing you to run project-specific code generators seamlessly within your development workflow.

Why use the go.mod tool directive over manual Go tool installation?

Using the go.mod `tool` directive guarantees that all developers and CI environments use the exact same tool versions, eliminating manual installation steps and ensuring reproducible builds across your project.