utils

package
v0.0.0-...-e081c89 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

README

utils

It's pretty bad form having a generic utils package I know. Eventually I expect this will be tidied up better.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewLineByte is a new line in POSIX systems (no carriage return) as []byte's
	NewLineByte []byte = []byte{'\n'}
	// NewLineString is a new line in POSIX systems (no carriage return) as a string
	NewLineString string = "\n"
)

Functions

func CrLfTrim

func CrLfTrim(b []byte) []byte

CrLfTrim removes the trailing carridge return and line feed from a byte array however it is only concerned with one instance (ie you can still append a CRLF to the data if you have two instances of a \r\n terminator). CrLfTrim creates a copy of the byte slice.

func CrLfTrimRune

func CrLfTrimRune(r []rune) []rune

CrLfTrimRune removes the trailing carridge return and line feed from a rune array however it is only concerned with one instance (ie you can still append a CRLF to the data if you have two instances of a \r\n terminator). CrLfTrimRune creates a copy of the rune slice.

func CrLfTrimString

func CrLfTrimString(s string) string

CrLfTrimString removes the trailing carridge return and line feed from a string however it is only concerned with one instance (ie you can still append a CRLF to the data if you have two instances of a \r\n terminator).

func Exists

func Exists(path string) bool

func IsURL

func IsURL(url string) bool

IsURL checks the start of a string to see if it has a valid HTTP protocol

func NormalisePath

func NormalisePath(path string) string

NormalisePath takes a string and returns an absolute path if the string is a relative path

Types

type TempFile

type TempFile struct {
	FileName string
	// contains filtered or unexported fields
}

TempFile is a struct returned by the NewTempFile function. It allows the receiver to us the temp file by filename wrapped inside an io.ReadCloser interface.

func NewTempFile

func NewTempFile(reader io.Reader, ext string) (*TempFile, error)

NewTempFile creates a temporary file and returns an io.Reader interface or error if the temporary file cannot be created.

func (*TempFile) Close

func (tmp *TempFile) Close() (err error)

Close the temporary file

func (*TempFile) Read

func (tmp *TempFile) Read(p []byte) (int, error)

Read is standard io.Reader method

Directories

Path Synopsis
Package ansi provides APIs for writing common ANSI escape sequences to the terminal
Package ansi provides APIs for writing common ANSI escape sequences to the terminal
codes
Package codes provides common ANSI escape sequences as constants
Package codes provides common ANSI escape sequences as constants
Package ansititle is a little function for writing to terminal emulators title bar
Package ansititle is a little function for writing to terminal emulators title bar
cd
Package cd changes the current working directory and updates the global working
Package cd changes the current working directory and updates the global working
cache
Package cache preemptively walks the file system to provide faster autocompletion suggestions
Package cache preemptively walks the file system to provide faster autocompletion suggestions
Package consts consolidates common values used throughout the source code
Package consts consolidates common values used throughout the source code
Package counter provides a thread safe counter using mutexes
Package counter provides a thread safe counter using mutexes
Package dedup provides de-duplication routines
Package dedup provides de-duplication routines
api
Package docgen contains all the executing code of the docgen CLI but in API form
Package docgen contains all the executing code of the docgen CLI but in API form
Package envvars provides a more pleasant framework around Go's stdlibs for working with environmental variables
Package envvars provides a more pleasant framework around Go's stdlibs for working with environmental variables
Package escape provides tools for escaping command line snippets of code
Package escape provides tools for escaping command line snippets of code
Package home is used to return the users home directory
Package home is used to return the users home directory
Package humannumbers is used to return human readable representations of numbers
Package humannumbers is used to return human readable representations of numbers
Package inject is used to insert one string inside another
Package inject is used to insert one string inside another
Package json is a custom json parser with an aim to provide more descriptive errors when reading malformed json
Package json is a custom json parser with an aim to provide more descriptive errors when reading malformed json
Package lists provides standard APIs for handling lists
Package lists provides standard APIs for handling lists
Package man is murex's man page parser to provide flag auto-complete suggestions
Package man is murex's man page parser to provide flag auto-complete suggestions
Package mxjson is a custom json superset format used by some routines in murex
Package mxjson is a custom json superset format used by some routines in murex
Package parser is a faster murex parser for real time context hints
Package parser is a faster murex parser for real time context hints
Package pathsplit is a standard API for splitting a path by the first character in the path
Package pathsplit is a standard API for splitting a path by the first character in the path
Package posix is a quick helper function to determine if the running platform is POSIX or not
Package posix is a quick helper function to determine if the running platform is POSIX or not
Package readall provides an alterative to ioutil.Readall but with support for context.Context
Package readall provides an alterative to ioutil.Readall but with support for context.Context
Package readline is a pure-Go re-imagining of the UNIX readline API
Package readline is a pure-Go re-imagining of the UNIX readline API
Package spellcheck provides functions for spellchecking
Package spellcheck provides functions for spellchecking
userdictionary
Package userdictionary provides `config` hooks for the spellchecker user dictionary
Package userdictionary provides `config` hooks for the spellchecker user dictionary
Package virtualterm provides a virtual terminal and some terminal emulation functions
Package virtualterm provides a virtual terminal and some terminal emulation functions
Package main provides a web server for user acceptance testing of js/wasm builds
Package main provides a web server for user acceptance testing of js/wasm builds
Package which provides similar functionality to the UNIX command of the same name
Package which provides similar functionality to the UNIX command of the same name

Jump to

Keyboard shortcuts

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