Documentation
¶
Index ¶
- func Abs(path string) core.Result
- func Base(path string) string
- func Chmod(path string, mode fs.FileMode) core.Result
- func Chtimes(path string, atime, mtime time.Time) core.Result
- func Clean(path string) string
- func CombinedOutput(ctx context.Context, dir string, env []string, command string, args ...string) core.Result
- func Create(path string) core.Result
- func DS() string
- func Dir(path string) string
- func Exec(ctx context.Context, command string, args ...string) core.Result
- func ExecDir(ctx context.Context, dir, command string, args ...string) core.Result
- func ExecWithEnv(ctx context.Context, dir string, env []string, command string, args ...string) core.Result
- func ExecWithWriters(ctx context.Context, dir string, env []string, stdout, stderr io.Writer, ...) core.Result
- func Exists(path string) bool
- func Ext(path string) string
- func FromSlash(path string) string
- func Geteuid() int
- func Getgid() int
- func Getuid() int
- func Getwd() core.Result
- func IsAbs(path string) bool
- func IsDir(path string) bool
- func IsFile(path string) bool
- func JSONMarshal(value any) core.Result
- func JSONUnmarshal(data []byte, target any) core.Result
- func Join(parts ...string) string
- func LookPath(name string) core.Result
- func Mkdir(path string, mode fs.FileMode) core.Result
- func MkdirAll(path string, _ fs.FileMode) core.Result
- func MkdirTemp(prefix string) core.Result
- func Open(path string) core.Result
- func ReadDir(path string) core.Result
- func ReadFile(path string) core.Result
- func Readlink(path string) core.Result
- func Rel(base, target string) core.Result
- func RemoveAll(path string) core.Result
- func ResolveCommand(name string, fallbackPaths ...string) core.Result
- func Run(ctx context.Context, command string, args ...string) core.Result
- func RunDir(ctx context.Context, dir, command string, args ...string) core.Result
- func Stat(path string) core.Result
- func TempDir(prefix string) core.Result
- func WriteFile(path string, data []byte, mode fs.FileMode) core.Result
- func WriteString(path, data string, mode fs.FileMode) core.Result
Examples ¶
- Abs
- Base
- Chmod
- Chtimes
- Clean
- CombinedOutput
- Create
- DS
- Dir
- Exec
- ExecDir
- ExecWithEnv
- ExecWithWriters
- Exists
- Ext
- FromSlash
- Geteuid
- Getgid
- Getuid
- Getwd
- IsAbs
- IsDir
- IsFile
- JSONMarshal
- JSONUnmarshal
- Join
- LookPath
- Mkdir
- MkdirAll
- MkdirTemp
- Open
- ReadDir
- ReadFile
- Readlink
- Rel
- RemoveAll
- ResolveCommand
- Run
- RunDir
- Stat
- TempDir
- WriteFile
- WriteString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs(path string) core.Result
Abs resolves a path against the current working directory.
Usage example: abs, err := ax.Abs("./testdata")
Example ¶
_ = Abs(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Abs")
Output: Abs
func Base ¶
Base returns the last path element.
Usage example: name := ax.Base("/tmp/dist/app.tar.gz")
Example ¶
_ = Base(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Base")
Output: Base
func Chmod ¶
Chmod updates file permissions without importing os.
Usage example: err := ax.Chmod("dist/app", 0o755)
Example ¶
_ = Chmod(core.Path(core.TempDir(), "go-build-compliance"), 0o755)
core.Println("Chmod")
Output: Chmod
func Chtimes ¶
Chtimes updates access and modification times without importing the OS package.
Usage example: err := ax.Chtimes("dist/app", modTime, modTime)
Example ¶
path := Join(core.TempDir(), "go-build-compliance-chtimes")
_ = WriteString(path, "agent", 0o644)
_ = Chtimes(path, time.Unix(123, 0), time.Unix(123, 0))
core.Println("Chtimes")
Output: Chtimes
func Clean ¶
Clean normalises a filesystem path using Core path primitives.
Usage example: clean := ax.Clean("./dist/../dist/output")
Example ¶
_ = Clean(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Clean")
Output: Clean
func CombinedOutput ¶
func CombinedOutput(ctx context.Context, dir string, env []string, command string, args ...string) core.Result
CombinedOutput executes a command and returns combined output.
Usage example: output, err := ax.CombinedOutput(ctx, repoDir, nil, "go", "test", "./...")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = CombinedOutput(ctx, core.Path(core.TempDir(), "go-build-compliance"), []string{"agent"}, "dappcore-command-not-found")
core.Println("CombinedOutput")
Output: CombinedOutput
func Create ¶
func Create(path string) core.Result
Create opens a file for writing via io.Local.
Usage example: file, err := ax.Create("dist/output.txt")
Example ¶
_ = Create(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Create")
Output: Create
func DS ¶
func DS() string
DS returns the current platform directory separator.
Usage example: read ax.DS() when building Core-aware filesystem paths.
Example ¶
--- v0.9.0 generated usage examples ---
_ = DS()
core.Println("DS")
Output: DS
func Dir ¶
Dir returns the parent directory for a path.
Usage example: dir := ax.Dir("/tmp/dist/app.tar.gz")
Example ¶
_ = Dir(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Dir")
Output: Dir
func Exec ¶
Exec executes a command without capturing output.
Usage example: err := ax.Exec(ctx, "go", "test", "./...")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = Exec(ctx, "dappcore-command-not-found")
core.Println("Exec")
Output: Exec
func ExecDir ¶
ExecDir executes a command in a specific directory without capturing output.
Usage example: err := ax.ExecDir(ctx, repoDir, "go", "test", "./...")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = ExecDir(ctx, core.Path(core.TempDir(), "go-build-compliance"), "dappcore-command-not-found")
core.Println("ExecDir")
Output: ExecDir
func ExecWithEnv ¶
func ExecWithEnv(ctx context.Context, dir string, env []string, command string, args ...string) core.Result
ExecWithEnv executes a command with additional environment variables.
Usage example: err := ax.ExecWithEnv(ctx, repoDir, []string{"GOOS=linux"}, "go", "build")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = ExecWithEnv(ctx, core.Path(core.TempDir(), "go-build-compliance"), []string{"agent"}, "dappcore-command-not-found")
core.Println("ExecWithEnv")
Output: ExecWithEnv
func ExecWithWriters ¶
func ExecWithWriters(ctx context.Context, dir string, env []string, stdout, stderr io.Writer, command string, args ...string) core.Result
ExecWithWriters executes a command and streams output to the provided writers.
Usage example: err := ax.ExecWithWriters(ctx, repoDir, nil, w, w, "docker", "build", ".")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = ExecWithWriters(ctx, core.Path(core.TempDir(), "go-build-compliance"), []string{"agent"}, core.NewBuffer(), core.NewBuffer(), "dappcore-command-not-found")
core.Println("ExecWithWriters")
Output: ExecWithWriters
func Exists ¶
Exists reports whether a path exists.
Usage example: if ax.Exists("dist") { ... }
Example ¶
_ = Exists(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Exists")
Output: Exists
func Ext ¶
Ext returns the filename extension including the dot.
Usage example: ext := ax.Ext("app.tar.gz")
Example ¶
_ = Ext(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Ext")
Output: Ext
func FromSlash ¶
FromSlash rewrites slash-separated paths for the current platform.
Usage example: path := ax.FromSlash("ui/dist/index.html")
Example ¶
_ = FromSlash(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("FromSlash")
Output: FromSlash
func Geteuid ¶
func Geteuid() int
Geteuid returns the effective UID.
Usage example: if ax.Geteuid() == 0 { ... }
Example ¶
_ = Geteuid()
core.Println("Geteuid")
Output: Geteuid
func Getgid ¶
func Getgid() int
Getgid returns the current process GID.
Usage example: gid := ax.Getgid()
Example ¶
_ = Getgid()
core.Println("Getgid")
Output: Getgid
func Getuid ¶
func Getuid() int
Getuid returns the current process UID.
Usage example: uid := ax.Getuid()
Example ¶
_ = Getuid()
core.Println("Getuid")
Output: Getuid
func Getwd ¶
func Getwd() core.Result
Getwd returns the current working directory from Core environment metadata.
Usage example: cwd, err := ax.Getwd()
Example ¶
_ = Getwd()
core.Println("Getwd")
Output: Getwd
func IsAbs ¶
IsAbs reports whether a path is absolute.
Usage example: if ax.IsAbs(outputDir) { ... }
Example ¶
_ = IsAbs(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("IsAbs")
Output: IsAbs
func IsDir ¶
IsDir reports whether a path is a directory.
Usage example: if ax.IsDir(".core") { ... }
Example ¶
_ = IsDir(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("IsDir")
Output: IsDir
func IsFile ¶
IsFile reports whether a path is a regular file.
Usage example: if ax.IsFile("go.mod") { ... }
Example ¶
_ = IsFile(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("IsFile")
Output: IsFile
func JSONMarshal ¶
func JSONMarshal(value any) core.Result
JSONMarshal returns a JSON string using Core's JSON wrapper.
Usage example: data, err := ax.JSONMarshal(cfg)
Example ¶
_ = JSONMarshal("agent")
core.Println("JSONMarshal")
Output: JSONMarshal
func JSONUnmarshal ¶
JSONUnmarshal decodes JSON into target using Core's JSON wrapper.
Usage example: err := ax.JSONUnmarshal(data, &cfg)
Example ¶
_ = JSONUnmarshal([]byte("agent"), "agent")
core.Println("JSONUnmarshal")
Output: JSONUnmarshal
func Join ¶
Join combines path segments without relying on path/filepath.
Usage example: path := ax.Join(projectDir, ".core", "build.yaml")
Example ¶
_ = Join()
core.Println("Join")
Output: Join
func LookPath ¶
func LookPath(name string) core.Result
LookPath resolves a program on PATH via the Core process package.
Usage example: path, err := ax.LookPath("git")
Example ¶
_ = LookPath("agent")
core.Println("LookPath")
Output: LookPath
func Mkdir ¶
Mkdir ensures a directory exists.
Usage example: err := ax.Mkdir(".core", 0o755)
Example ¶
_ = Mkdir(core.Path(core.TempDir(), "go-build-compliance"), 0o755)
core.Println("Mkdir")
Output: Mkdir
func MkdirAll ¶
MkdirAll ensures a directory exists.
Usage example: err := ax.MkdirAll("dist/linux_arm64", 0o755)
Example ¶
_ = MkdirAll(core.Path(core.TempDir(), "go-build-compliance"), 0o755)
core.Println("MkdirAll")
Output: MkdirAll
func MkdirTemp ¶
func MkdirTemp(prefix string) core.Result
MkdirTemp creates a temporary directory via Core's filesystem primitive.
Usage example: dir, err := ax.MkdirTemp("core-build-*")
Example ¶
_ = MkdirTemp("agent")
core.Println("MkdirTemp")
Output: MkdirTemp
func Open ¶
func Open(path string) core.Result
Open opens a file for reading via io.Local.
Usage example: file, err := ax.Open("README.md")
Example ¶
_ = Open(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Open")
Output: Open
func ReadDir ¶
func ReadDir(path string) core.Result
ReadDir lists directory entries via io.Local.
Usage example: entries, err := ax.ReadDir("dist")
Example ¶
_ = ReadDir(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("ReadDir")
Output: ReadDir
func ReadFile ¶
func ReadFile(path string) core.Result
ReadFile reads a file into bytes via io.Local.
Usage example: data, err := ax.ReadFile("go.mod")
Example ¶
_ = ReadFile(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("ReadFile")
Output: ReadFile
func Readlink ¶
func Readlink(path string) core.Result
Readlink reads a symbolic link target without importing the OS package.
Usage example: target, err := ax.Readlink("dist/current")
Example ¶
dir := core.TempDir()
link := Join(dir, "go-build-compliance-link")
_ = syscall.Symlink("target", link)
_ = Readlink(link)
core.Println("Readlink")
Output: Readlink
func Rel ¶
func Rel(base, target string) core.Result
Rel returns target relative to base when target is inside base.
Usage example: rel, err := ax.Rel(projectDir, artifactPath)
Example ¶
_ = Rel("agent", "linux")
core.Println("Rel")
Output: Rel
func RemoveAll ¶
func RemoveAll(path string) core.Result
RemoveAll removes a file or directory tree.
Usage example: err := ax.RemoveAll("dist")
Example ¶
_ = RemoveAll(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("RemoveAll")
Output: RemoveAll
func ResolveCommand ¶
ResolveCommand resolves a program from PATH or a list of fallback paths.
Usage example: path, err := ax.ResolveCommand("task", "/opt/homebrew/bin/task")
Example ¶
_ = ResolveCommand("agent")
core.Println("ResolveCommand")
Output: ResolveCommand
func Run ¶
Run executes a command and returns trimmed combined output.
Usage example: output, err := ax.Run(ctx, "git", "status", "--short")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = Run(ctx, "dappcore-command-not-found")
core.Println("Run")
Output: Run
func RunDir ¶
RunDir executes a command in the provided directory and returns combined output.
Usage example: output, err := ax.RunDir(ctx, repoDir, "git", "show", "--stat")
Example ¶
ctx, cancel := core.WithCancel(core.Background())
cancel()
_ = RunDir(ctx, core.Path(core.TempDir(), "go-build-compliance"), "dappcore-command-not-found")
core.Println("RunDir")
Output: RunDir
func Stat ¶
func Stat(path string) core.Result
Stat returns file metadata from io.Local.
Usage example: info, err := ax.Stat("go.mod")
Example ¶
_ = Stat(core.Path(core.TempDir(), "go-build-compliance"))
core.Println("Stat")
Output: Stat
func TempDir ¶
func TempDir(prefix string) core.Result
TempDir creates a temporary directory via Core's filesystem primitive.
Usage example: dir, err := ax.TempDir("core-build-*")
Example ¶
_ = TempDir("agent")
core.Println("TempDir")
Output: TempDir
func WriteFile ¶
WriteFile writes bytes via io.Local with an explicit mode.
Usage example: err := ax.WriteFile("README.md", []byte("hi"), 0o644)
Example ¶
_ = WriteFile(core.Path(core.TempDir(), "go-build-compliance"), []byte("agent"), 0o755)
core.Println("WriteFile")
Output: WriteFile
func WriteString ¶
WriteString writes text via io.Local with an explicit mode.
Usage example: err := ax.WriteString("README.md", "hi", 0o644)
Example ¶
_ = WriteString(core.Path(core.TempDir(), "go-build-compliance"), "agent", 0o755)
core.Println("WriteString")
Output: WriteString
Types ¶
This section is empty.