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

deps

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Docker describes the docker dependency
	Docker = &Dependency{
		Bin: "docker",
	}
	// Yamllint describes the yamllint dependency
	Yamllint = &Dependency{
		Bin: "yamllint",
	}
	// Golint describes the golint dependency
	Golint = &Dependency{
		Bin:       "golint",
		GoInstall: []string{"golang.org/x/lint/golint@latest"},
	}
	// Htmltest describes the htmltest dependency
	Htmltest = &Dependency{
		Bin:       "htmltest",
		GoInstall: []string{"github.com/wjdp/htmltest@latest"},
	}
	// Hugo describes the hugo dependency
	Hugo = &Dependency{
		Bin:       "hugo",
		Env:       map[string]string{"CGO_ENABLED": "1"},
		GoInstall: []string{"-tags", "extended", "github.com/gohugoio/hugo@latest"},
	}
	// DartSass describes the Dart Sass dependency (https://sass-lang.com).
	// Version is intentionally unset — the latest published release is resolved
	// automatically via the GitHub API. Pin it in consumer code when reproducibility
	// is required:
	//
	//	deps.DartSass.GithubRelease.Version = "1.103.1"
	DartSass = &Dependency{
		Bin: "sass",
		GithubRelease: &GithubRelease{
			Repo:         "sass/dart-sass",
			AssetPattern: "dart-sass-{{.Version}}-{{.OS}}-{{.Arch}}.tar.gz",
			BundleDir:    "dart-sass",
			BinPath:      "dart-sass/sass",
		},
	}
)
View Source
var (
	// ExternalDependencies define the external app dependencies needed
	// to fullfill all automation tasks
	ExternalDependencies = []*Dependency{
		Golint,
	}
)

Functions

func CheckDependencies

func CheckDependencies(ctx context.Context, dependencies ...*Dependency) error

CheckDependencies determines if provided dependencies are available. If binary is not available os.ErrNotExist is returned

func InstallDependencies

func InstallDependencies(ctx context.Context, dependencies ...*Dependency) (bool, error)

InstallDependencies makes sure to install provided dependencies and return if all installing all dependencies were successful

Types

type Dependency

type Dependency struct {
	// Bin is the executable name used for PATH lookup and as the installed binary name.
	Bin string
	// GoInstall holds the arguments passed to `go install` (build flags + package path).
	// Example: []string{"-tags", "extended", "github.com/gohugoio/hugo@latest"}
	GoInstall []string
	// Env holds optional environment variables set when running go install.
	// Example: map[string]string{"CGO_ENABLED": "1"}
	Env map[string]string
	// GithubRelease, when set, installs the binary by downloading a GitHub Releases asset.
	// Mutually exclusive with GoInstall.
	GithubRelease *GithubRelease
}

Dependency encapsulates attributes of a depending application. Exactly one install strategy field should be set (GoInstall or GithubRelease). If none is set, installation is a no-op with a warning; the binary is expected to be provided externally.

func (*Dependency) Install

func (d *Dependency) Install(ctx context.Context) (result bool, err error)

Install will install the dependency

type GithubRelease added in v1.7.0

type GithubRelease struct {
	// Repo is the GitHub repository in "owner/repo" form.
	// Example: "sass/dart-sass"
	Repo string

	// Version is the release tag to install, e.g. "1.103.1".
	// Leave empty to resolve the latest published release automatically via the GitHub API.
	// Pin this in consumer code when reproducibility matters:
	//   deps.DartSass.GithubRelease.Version = "1.103.1"
	Version string

	// AssetPattern is a Go text/template that is rendered with [ReleaseAssetData] to produce
	// the release asset filename to download.
	// Example: "dart-sass-{{.Version}}-{{.OS}}-{{.Arch}}.tar.gz"
	AssetPattern string

	// BinPath is the path to the executable inside the archive, always relative to the
	// archive root — regardless of whether BundleDir is set.
	//
	// Single-binary install (BundleDir empty): the file at BinPath is copied to
	// InstallDir/Dependency.Bin.
	//
	// Bundle install (BundleDir set): BinPath locates the entry-point within the installed
	// bundle; a symlink InstallDir/Dependency.Bin → InstallDir/BinPath is created so the
	// binary appears on PATH while the bundle's internal layout stays intact.
	//
	// Example: "dart-sass/sass"
	BinPath string

	// BundleDir is the top-level directory inside the archive that must be installed as a
	// whole unit. Set this when the entry-point binary is a wrapper script (or otherwise
	// not a self-contained executable) that depends on sibling files at a fixed relative
	// path within the same directory.
	//
	// When set, the entire subtree is copied to InstallDir/BundleDir and a symlink is
	// created at InstallDir/Dependency.Bin pointing to InstallDir/BinPath.
	//
	// Leave empty for self-contained binaries that can be freely relocated.
	//
	// Example: "dart-sass"
	BundleDir string

	// InstallDir is the directory into which the binary (or bundle) is placed.
	// Defaults to $GOPATH/bin, falling back to $HOME/.local/bin.
	// Override when a specific location is required.
	InstallDir string
}

GithubRelease describes how to install a Dependency from a GitHub Releases asset.

Minimal example — single relocatable binary, always latest:

&GithubRelease{
    Repo:         "cli/cli",
    AssetPattern: "gh_{{.Version}}_{{.OS}}_{{.Arch}}.tar.gz",
    BinPath:      "gh_{{.Version}}_{{.OS}}_{{.Arch}}/bin/gh",
}

Bundle example — wrapper script with runtime siblings (e.g. Dart Sass):

&GithubRelease{
    Repo:         "sass/dart-sass",
    AssetPattern: "dart-sass-{{.Version}}-{{.OS}}-{{.Arch}}.tar.gz",
    BundleDir:    "dart-sass",
    BinPath:      "dart-sass/sass",
}

type Installable

type Installable interface {
	Install() error
}

Installable describes something that can be installed

type ReleaseAssetData added in v1.7.0

type ReleaseAssetData struct {
	// Version is the resolved release tag, e.g. "1.103.1".
	Version string
	// OS is the GOOS-derived platform token used in release asset names.
	// Mapping: darwin → "macos", windows → "windows", anything else → "linux".
	OS string
	// Arch is the GOARCH-derived architecture token used in release asset names.
	// Mapping: arm64 → "arm64", arm → "arm", anything else → "x64".
	Arch string
}

ReleaseAssetData is the template context passed to GithubRelease.AssetPattern. All fields are populated automatically from the resolved version and the current platform at install time.

Jump to

Keyboard shortcuts

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