util

package
v0.0.0-...-c211321 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atoi

func Atoi(s string) int

Atoi converts a string to an integer in cases where we are sure that s will be a valid integer, otherwise it will panic.

func GetExportedName

func GetExportedName(field string) string

GetExportedName returns a deterministic and Go safe name for a C type. For example, "*__foo[]" will return "FooSlice".

func GetRegex

func GetRegex(rx string) *regexp.Regexp

GetRegex return regexp added for minimaze regexp compilation

func GroupsFromRegex

func GroupsFromRegex(rx, line string) map[string]string

GroupsFromRegex gets RegExp groups after matching it on a line

func InStrings

func InStrings(item string, items []string) bool

InStrings returns true if item exists in items. It must be an exact string match.

func PanicIfNil

func PanicIfNil(check interface{}, message string)

PanicIfNil will panic with the message provided if the check is nil. This is a convieniance method to avoid many similar if statements.

func PanicOnError

func PanicOnError(err error, message string)

PanicOnError will panic with the message and error if the error is not nil. If the error is nil (no error) then nothing happens.

func ShowDiff

func ShowDiff(a, b string) string

ShowDiff will print two strings vertically next to each other so that line differences are easier to read.

func Ucfirst

func Ucfirst(word string) string

Ucfirst returns the word with the first letter uppercased; none of the other letters in the word are modified. For example "fooBar" would return "FooBar".

Types

This section is empty.

Jump to

Keyboard shortcuts

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