runtime

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommentPrefix = "//"
	MaxWidth      = 100
)
View Source
const PluralSuffix = "List"
View Source
const Timeout = time.Second * 15

Variables

View Source
var ErrRuntime = Error("runtime")
View Source
var Funcs = map[string]any{

	"camel":      kace.Camel,
	"kebab":      kace.Kebab,
	"kebabUpper": kace.KebabUpper,
	"pascal":     kace.Pascal,
	"snake":      kace.Snake,
	"snakeUpper": kace.SnakeUpper,
	"unchanged":  Unchanged,

	"fields":       strings.Fields,
	"indexAny":     strings.IndexAny,
	"lastIndex":    strings.LastIndex,
	"lastIndexAny": strings.LastIndexAny,
	"replaceAll":   strings.ReplaceAll,
	"strIndex":     strings.Index,
	"trimLeft":     strings.TrimLeft,
	"trimRight":    strings.TrimRight,
	"trimPrefix":   strings.TrimPrefix,
	"trimSuffix":   strings.TrimSuffix,

	"pluralName":       inflection.Plural,
	"pluralUniqueName": PluralUnique,
	"singular":         inflection.Singular,

	"pad":         Pad,
	"notEmpty":    NotEmpty,
	"version":     cfg.Version,
	"toSlice":     ToSlice,
	"numbers":     Numbers,
	"sum":         Sum,
	"inc":         Inc,
	"replaceEach": ReplaceEach,
	"fileWithExt": FileWithExt,
	"isNil":       IsNil,
	"isNotNil":    IsNotNil,
	"in":          In,

	"backQuote": BackQuote,
	"csv":       Csv,
	"goToken":   GoToken,
	"goDoc":     GoDoc,
	"goComment": GoComment,
	"isGoType":  IsGoType,

	"blue":       color.Blue,
	"color":      color.ByName,
	"colors":     color.ByNames,
	"colorReset": color.Clear,
	"cyan":       color.Cyan,
	"green":      color.Green,
	"magenta":    color.Magenta,
	"red":        color.Red,
	"yellow":     color.Yellow,
}

Functions

func BackQuote

func BackQuote(in string) string

func Case

func Case(name string) any

func CaseFuncs

func CaseFuncs(name string) map[string]any

func Cases

func Cases(name string) any

func Csv

func Csv(in stringlist.Strings) string

func FileWithExt

func FileWithExt(path, ext string) string

func GoComment added in v0.0.6

func GoComment(s string) string

GoComment appends CommentPrefix to each newline and trims trailing empty lines

func GoDoc

func GoDoc(s string) string

GoDoc wraps the string to a MaxWidth and prepends with CommentPrefix.

func GoToken

func GoToken(in string) string

GoToken converts the in string into a valid Go Token by converting "/" an ".". It also filters for reserved words.

func In

func In(needle any, haystack ...any) (bool, error)

func Inc

func Inc(x int) int

Inc increments the argument's value by 1.

func Invoke

func Invoke(file string, commandLine []string) error

func IsGoType added in v0.1.5

func IsGoType(token string) bool

func IsNil

func IsNil(i any) bool

IsNil returns true if the input or referenced object is nil.

func IsNotNil

func IsNotNil(i any) bool

IsNotNil returns false if the input or referenced object is nil.

func NotEmpty

func NotEmpty(in string) bool

func Numbers

func Numbers(start, end int) stringlist.Strings

numbers returns a slice of strings of the numbers start to end (inclusive).

func Pad

func Pad(s string, size int) string

func PluralUnique

func PluralUnique(s string) string

PluralUnique guarantees a unique name for a Plural of the input.

func ReplaceEach

func ReplaceEach(s, newString string, olds ...string) string

func Sum

func Sum(vv ...int) int

Sum returns the sum of its arguments.

func ToSlice

func ToSlice(vv ...any) any

ToSlice returns the arguments as a single slice. If all the arguments are strings, they are returned as a stringlist.Strings, otherwise they're returned as []any.

func Unchanged

func Unchanged(s string) string

Unchanged is used as a Case function that does not alter the string.

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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