Documentation
¶
Index ¶
- Variables
- func AllNils[T comparable](vals []*T) bool
- func CreateFilePathAndWriteJson(path string, jsonData interface{}) error
- func CreateFilePathAndWriteString(path string, str string) error
- func DeleteFileIfExists(relativePath string) error
- func Dump(item any) string
- func FileExists(path string) bool
- func Int64Max(a, b int64) int64
- func Int64Min(a, b int64) int64
- func IntMax(a, b int) int
- func IntMin(a, b int) int
- func IsBlank(str string) bool
- func IsWindows() bool
- func LoadJson(path string) (interface{}, error)
- func Memoize[T any](f func() T) func() T
- func NormalizeLineEndings(s string) string
- func NormalizePath(path string) string
- func NotNil[T comparable](val *T, nilProvider func() T) bool
- func NumIsAre(values int) string
- func Pluralize(count int, singular string) string
- func PluralizeCustom(count int, singular string, plural string) string
- func Reverse(str string) string
- func SortedKeys[T any](m map[string]T) []string
- func StrLen(str string) int
- func ToAbsoluteNormalizedPath(path string) string
- func ToAbsolutePath(path string) string
- func Truncate(str string, maxLen int64) string
- type LoadFileResult
- type Rgb
- type Stack
Constants ¶
This section is empty.
Variables ¶
var ( PlainF = plain.FprintfFunc() GreenF = green.FprintfFunc() GreenBoldF = greenBold.FprintfFunc() YellowF = yellow.FprintfFunc() CyanF = cyan.FprintfFunc() BoldF = bold.FprintfFunc() PlainS = plain.SprintfFunc() GreenS = green.SprintfFunc() GreenBoldS = greenBold.SprintfFunc() YellowS = yellow.SprintfFunc() CyanS = cyan.SprintfFunc() BoldS = bold.SprintfFunc() )
var ( IsTty = checkTty() TerminalIsUtf8 = checkTerminalUtf8() )
Functions ¶
func AllNils ¶
func AllNils[T comparable](vals []*T) bool
func DeleteFileIfExists ¶
func FileExists ¶
func IsWindows ¶ added in v0.7.1
func IsWindows() bool
IsWindows returns true if running on Windows.
func NormalizeLineEndings ¶ added in v0.7.1
NormalizeLineEndings converts Windows-style line endings (\r\n) to Unix-style (\n). This ensures consistent text handling across platforms.
Call this on text content read from files before returning to user code.
func NormalizePath ¶ added in v0.7.1
NormalizePath converts OS-specific path separators to forward slashes. This ensures Rad scripts are portable across platforms - forward slashes work on all operating systems, including Windows.
Call this on any path before returning it to user code.
func NotNil ¶
func NotNil[T comparable](val *T, nilProvider func() T) bool
this is the best way I can think of to do the 'typed nil' check...
func SortedKeys ¶
func StrLen ¶
Simple len(str) call counts bytes, not runes, so e.g. emojis gets counted as multiple characters
func ToAbsoluteNormalizedPath ¶ added in v0.7.1
ToAbsoluteNormalizedPath expands ~ to home directory, resolves to absolute path, and normalizes to forward slashes. This is the standard way to process user-provided paths before returning them.
func ToAbsolutePath ¶
Types ¶
type LoadFileResult ¶
func LoadFile ¶
func LoadFile(path string) LoadFileResult