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

buildid

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package buildid names the lfm binary that is running, for the keys of the files it writes: a file built by another lfm, whose writer may differ, is never taken for one this lfm would write.

Index

Constants

This section is empty.

Variables

View Source
var Writer = sync.OnceValue(func() string {
	info, ok := debug.ReadBuildInfo()
	revision, modified := "", false
	if ok {
		for _, s := range info.Settings {
			switch s.Key {
			case "vcs.revision":
				revision = s.Value
			case "vcs.modified":
				modified = s.Value == "true"
			}
		}
	}
	if ok && revision != "" && !modified {
		return info.Main.Version + "+" + revision
	}
	if exe, err := os.Executable(); err == nil {
		if st, err := os.Stat(exe); err == nil {
			return fmt.Sprintf("local+%d+%d", st.Size(), st.ModTime().UnixNano())
		}
	}
	return "unknown"
})

Writer identifies this binary: its module version and VCS revision, or, for a build with local changes or none recorded (go test, go run), the executable's size and modification time, which change with every build.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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