Documentation
¶
Overview ¶
Package fuigo wraps "go install" with optional pre-build steps. It reads a fuigo.yaml from the target module (fetched from the Go module proxy), runs the declared steps, then delegates to go install. Without a fuigo.yaml it behaves exactly like go install.
Index ¶
- Constants
- func ExecuteSteps(root string, steps []Step, builtins Builtins) error
- func Install(dir, relPkg string) error
- func InstallDir() string
- func ResolveModule(pkg, version string) (srcDir string, resolved string, cleanup func(), err error)
- func Run(opts Options) error
- func SplitModulePath(pkg string) (module, relPkg string)
- type Builtins
- type Config
- type Options
- type Step
Constants ¶
const ConfigFile = "fuigo.yaml"
ConfigFile is the name of the per-module configuration file fuigo looks for.
Variables ¶
This section is empty.
Functions ¶
func ExecuteSteps ¶
ExecuteSteps runs each step with root as the module root. A step is dispatched by its first token: "go" runs the external go tool; "npmgo" and "esbuild" invoke the built-in libraries. Any other command is rejected. When a step sets a Workdir it runs in root/Workdir, which must stay within root. Execution stops at the first failing step, returning an error that names it.
func Install ¶
Install delegates to "go install" for the package at relPkg within the module source rooted at dir. relPkg is the package path relative to the module root (e.g. "cmd/shoka"); an empty relPkg installs the module root package. Output is streamed live.
func InstallDir ¶
func InstallDir() string
InstallDir reports the directory go install writes binaries to: GOBIN if set, otherwise GOPATH/bin.
func ResolveModule ¶
ResolveModule fetches the source of the module containing pkg at the given version and extracts it to a temporary directory. version may be "", "latest" or an explicit "vX.Y.Z". It returns the extracted source directory, a cleanup function that removes it, and the resolved concrete version.
The primary path downloads a zip from the Go module proxy (no git). If the module is not available on the proxy (e.g. GOPRIVATE repositories) it falls back to a shallow git clone via go-git.
func Run ¶
Run resolves the target module, runs any pre-build steps and installs the package. It is the entry point used by the CLI.
func SplitModulePath ¶
SplitModulePath splits a full package import path into its module root and the package path relative to that root. For the common VCS hosts the module root is host/owner/repo; e.g. "github.com/sopranoworks/shoka/cmd/shoka" becomes module "github.com/sopranoworks/shoka" and relPkg "cmd/shoka".
Types ¶
type Builtins ¶
type Builtins struct {
Npmgo func(dir string, args []string) error
Esbuild func(dir string, args []string) error
Logf func(format string, args ...any)
}
Builtins holds the implementations fuigo dispatches built-in steps to. They are injectable so tests can substitute fakes. Logf, when set, receives progress messages; a nil Logf discards them.
func DefaultBuiltins ¶
DefaultBuiltins returns Builtins wired to the compiled-in npmgo and esbuild libraries, logging progress through logf.
type Config ¶
type Config struct {
Steps []Step `yaml:"steps"`
}
Config is the parsed contents of a module's fuigo.yaml.
func LoadConfig ¶
LoadConfig reads fuigo.yaml from dir. If the file does not exist it returns (nil, nil): a module without a fuigo.yaml is valid and means "plain go install". Any present config is validated: steps must be non-empty and every step must start with one of the allowed commands.
type Options ¶
type Options struct {
// Package is the target package path, optionally with an "@version" suffix
// (e.g. "github.com/sopranoworks/shoka/cmd/shoka@latest").
Package string
// Yes skips the confirmation prompt before executing steps.
Yes bool
// List prints the pre-build steps without executing anything.
List bool
// Logf receives progress messages (without a trailing newline). If nil,
// messages are discarded.
Logf func(format string, args ...any)
// In is the source of the confirmation answer; defaults handled by caller.
In io.Reader
// Out is where the confirmation prompt is written.
Out io.Writer
}
Options configures a Run.
type Step ¶ added in v0.1.1
Step is a single pre-build step. It is either a bare command (string form) or a command plus a workdir (map form). Workdir is a path relative to the module root; an empty Workdir means the module root itself.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fuigo
command
Command fuigo is a drop-in "go install" replacement that runs a module's declared pre-build steps (from fuigo.yaml) before installing.
|
Command fuigo is a drop-in "go install" replacement that runs a module's declared pre-build steps (from fuigo.yaml) before installing. |