util

package
v0.0.0-...-b679203 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HOME string

HOME is user's home dir

Functions

func BaseNoExt

func BaseNoExt(path string) string

BaseNoExt returns the base without its extension from the last path segment.

func Clamp

func Clamp(x, min, max int) int

func CustomizeSlog

func CustomizeSlog(filename string)

CustomizeSlog initializes slog.

func Homify

func Homify(p string, home string) string

Homify replace home with "~".

func ParseIntOr

func ParseIntOr(x string, or int) int

func Tildify

func Tildify(p string) string

Tildify replace $HOME with "~".

func Unhomify

func Unhomify(path string, home string) string

Unhomify replaces leading "~" with user's home directory.

func Untildify

func Untildify(path string) string

Untildify replaces leading "~" with user's home directory.

Types

type CommandResult

type CommandResult struct {
	Output []byte `json:"stdout"`
	RC     int    `json:"rc"`
}

func Bash

func Bash(statement string) (*CommandResult, error)

func Bashf

func Bashf(format string, args ...any) (*CommandResult, error)

func Exec

func Exec(statement string) (*CommandResult, error)

func ExecWithStdin

func ExecWithStdin(statement string, stdinText string) (*CommandResult, error)

func Execf

func Execf(format string, args ...any) (*CommandResult, error)

type TeeWriter

type TeeWriter struct {
	// contains filtered or unexported fields
}

func (*TeeWriter) Write

func (t *TeeWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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