Help us shape the future of Go! Take the 2026 Go Developer Survey

toolpin

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package toolpin answers one question for every forge surface that runs buf: which buf does THIS project pin?

buf had two pins in one project. forge pinned it (templates.BufVersion, what `forge ci gate` holds PATH to and the scaffolded ci.yml installs), and a project that needed another release kept its own copy of the decision — a Makefile BUF_VERSION smuggled into forge through $BUF and PATH (reliant: buf 1.57.0 against forge's 1.50.0). The two answers drifted, and which buf generated a file depended on whether forge or the Makefile started it.

Now the project's go.mod is the one place it is declared, exactly as it is for protoc-gen-go and protoc-gen-connect-go: a project that pins buf says so with a tool directive,

go get -tool github.com/bufbuild/buf/cmd/buf@v1.57.0

and every forge surface — `forge generate`, `forge ci gate` (verify-generated and buf-lint), `forge tools install buf`, `forge tools pins buf`, and the ci.yml forge scaffolds — runs that release. A project that declares none runs forge's pin. Dependabot moves the go.mod line like any other.

Index

Constants

View Source
const BufModule = "github.com/bufbuild/buf"

BufModule is buf's Go module; a go.mod that requires it (as a tool directive does) pins the buf the project runs.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buf

type Buf struct {
	// Version is a Go module version, with its leading v ("v1.57.0").
	Version string
	Source  Source
}

Buf is the buf a project runs.

func BufFor

func BufFor(projectDir string) Buf

BufFor returns the buf projectDir pins: go.mod's BufModule when the module graph has it, forge's pin otherwise. projectDir "" (no project) is forge's pin. Memoised per directory for the life of the process.

func ForgeBuf

func ForgeBuf() Buf

ForgeBuf is forge's own pin.

func (Buf) Bare

func (b Buf) Bare() string

Bare is Version without its leading v ("1.57.0"), the spelling bufbuild/buf-setup-action and `buf --version` use.

func (Buf) Declared

func (b Buf) Declared() bool

Declared reports whether the project pins buf itself.

type Source

type Source string

Source says where a resolved buf version came from.

const (
	// FromGoMod is the project's go.mod requiring BufModule.
	FromGoMod Source = "go.mod"
	// FromForge is forge's own pin, for a project that declares none.
	FromForge Source = "forge"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL