utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePerms = 0o644 // -rw-r--r--
	DirPerms  = 0o755 // drwxr-xr-x
)

Variables

This section is empty.

Functions

func CheckRW

func CheckRW(mode fs.FileMode) error

Check for rw------- perms

func CheckRWX

func CheckRWX(mode fs.FileMode) error

Check for rwx------ perms

func CleanString

func CleanString(s string, othersToEscape ...rune) string

Escapes the given string from common escape sequences in 0(n) time, no regex.

\x1b[31mfoo\x1b[0m -> foo
\n\r\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x7f -> empty

func CleanStringNoRegex

func CleanStringNoRegex(s string) string

Invokes CleanString to prevent regex

func EscapeTermString

func EscapeTermString(s string) string

Invokes CleanString with terminal-specific operators like ;|&$.

func IsDir

func IsDir(path string) (bool, error)

func IsExecutableFile

func IsExecutableFile(path string) (bool, error)

func IsFile

func IsFile(path string) (bool, error)

func MultilineString

func MultilineString(s ...string) string

MultilineString provides a pleasing way to write multiline strings.

func ParseLicenseText

func ParseLicenseText(tmpl map[string]string, s string) string

ParseLicenseText handles templating license text

func ParseTemplateFile

func ParseTemplateFile(ctx context.Context, tmpl map[string]any, reader *bufio.Scanner, writer *bufio.Writer) error

This handles consuming a file stream, templating it and writing it to writer.

tmpl is a mapping of `find`: `replace`.

`find` should be X where the actual template searched for is "{{X}}" {{{x}}}

Time complexity through the roof: HAVE TO OPTIMIZE

func PathExists

func PathExists(path string) (bool, error)

func StringStartsWith

func StringStartsWith(s, look string) bool

StringStartsWith returns true if the given string starts with the given string look, or if they start similarly.

func WalkDirRecursive

func WalkDirRecursive(root string) ([]string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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