install

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package install copies registry source into a project, rewriting import paths so the installed code compiles immediately under the user's module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashRewritten

func HashRewritten(opts Options) (string, error)

HashRewritten runs the same copy/rewrite pipeline Copy uses, but into a throwaway temp directory, and returns the content hash of the result. It does not touch the user's project.

This exists so check can compute "what would upstream hash as if it were installed" — matching the UpstreamHash recorded by pull/update even when import rewriting reformats files.

func IsModified

func IsModified(destDir, recordedLocalHash string) (bool, string, error)

IsModified reports whether the installed package at destDir differs from its recorded local hash. A missing dir is treated as modified (it was deleted).

func ResolvePackage

func ResolvePackage(pkg string, sources []string) (*registry.Fetcher, *registry.Manifest, error)

ResolvePackage finds pkg across the given registry sources, returning the first Fetcher that contains it. The caller must Close the returned Fetcher.

If pkg itself is a direct source (URL or local path, per registry.IsDirectSource), it is resolved directly and the registries list is ignored. The returned Fetcher is in direct mode: the materialized directory is the package itself.

Types

type Options

type Options struct {
	// SrcDir is the package source directory in the materialized registry.
	SrcDir string
	// DestDir is the absolute install path in the user's project.
	DestDir string
	// PkgName is the package directory name (e.g. "ptr").
	PkgName string
	// ModuleImportPath is the user's module path joined with the install
	// dir, e.g. "github.com/me/proj/pkg/gocp".
	ModuleImportPath string
	// RegistryImportPath is the import path prefix of the registry's
	// packages as they appear in upstream source, e.g.
	// "github.com/fritzkeyzer/gocp/registry". Imports under this prefix
	// are rewritten to ModuleImportPath so inter-package deps resolve
	// locally after install.
	RegistryImportPath string
}

Options controls a single package install.

type Result

type Result struct {
	Package      string
	Source       string
	UpstreamHash string
	LocalHash    string
	Files        []string
}

Result describes what was installed.

func Copy

func Copy(opts Options) (*Result, error)

Copy installs a single package: it copies every regular file from SrcDir into DestDir, rewriting Go import paths along the way.

Copy does not touch the lockfile — the caller is responsible for recording Result. It does clear the destination directory first so deleted upstream files don't linger.

Jump to

Keyboard shortcuts

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