type Sandbox … type SandboxConfig … // NewSandbox creates a collection of named temporary resources, with a // working directory populated by the txtar-encoded content in srctxt, and a // file-based module proxy populated with the txtar-encoded content in // proxytxt. // // If rootDir is non-empty, it will be used as the root of temporary // directories created for the sandbox. Otherwise, a new temporary directory // will be used as root. // // TODO(rfindley): the sandbox abstraction doesn't seem to carry its weight. // Sandboxes should be composed out of their building-blocks, rather than via a // monolithic configuration. func NewSandbox(config *SandboxConfig) (_ *Sandbox, err error) { … } func UnpackTxt(txt string) map[string][]byte { … } func validateConfig(config SandboxConfig) error { … } // splitModuleVersionPath extracts module information from files stored in the // directory structure modulePath@version/suffix. // For example: // // splitModuleVersionPath("[email protected]/package") = ("mod.com", "v1.2.3", "package") func splitModuleVersionPath(path string) (modulePath, version, suffix string) { … } func (sb *Sandbox) RootDir() string { … } // GOPATH returns the value of the Sandbox GOPATH. func (sb *Sandbox) GOPATH() string { … } // GoEnv returns the default environment variables that can be used for // invoking Go commands in the sandbox. func (sb *Sandbox) GoEnv() map[string]string { … } // goCommandInvocation returns a new gocommand.Invocation initialized with the // sandbox environment variables and working directory. func (sb *Sandbox) goCommandInvocation() gocommand.Invocation { … } // RunGoCommand executes a go command in the sandbox and returns its standard // output. If checkForFileChanges is true, the sandbox scans the working // directory and emits file change events for any file changes it finds. func (sb *Sandbox) RunGoCommand(ctx context.Context, dir, verb string, args, env []string, checkForFileChanges bool) ([]byte, error) { … } // GoVersion checks the version of the go command. // It returns the X in Go 1.X. func (sb *Sandbox) GoVersion(ctx context.Context) (int, error) { … } // Close removes all state associated with the sandbox. func (sb *Sandbox) Close() error { … }