utils

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromByteArray added in v1.2.1

func FromByteArray[T any](b []byte) (s T)

Helper function that converts byte slice to type T.

func ToBool

func ToBool(i interface{}) bool

Convert any variable to bool.

In most cases it returns true if i > 0.

func ToByteArray added in v1.2.1

func ToByteArray[T any](s T) (b []byte)

Helper function that converts type T to byte slice.

func ToNumber

func ToNumber[T number](i interface{}) T

Try to convert any variable to number T (int64 | uint64 | float64).

It doesn't convert slices, arrays and structs.

func WordsEqual added in v1.1.0

func WordsEqual(a, b []Word) bool

Is two words equal.

Types

type Word added in v1.1.0

type Word struct {
	Type    WordType
	Literal string
}

func ParsePrompt added in v1.1.1

func ParsePrompt(str string) []Word

This functions splits provided string into words and determines its basic types.

type WordType added in v1.4.0

type WordType int
const (
	// Not word.
	W_NONE WordType = iota
	// Number in scientific notation.
	W_NUM_SCI
	// Number in decimal representation.
	W_NUM_DEC
	// Number in hexadecimal representation.
	W_NUM_HEX
	// Number in binary representation.
	W_NUM_BIN
	// Some variable, constant or function.
	W_UNIT
	// Operator.
	W_OP
	// Flow control (brackets).
	W_CTL
	// Detected function call.
	W_FUNC
	// String.
	W_STR
)

Word types

Jump to

Keyboard shortcuts

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