strutil

package module
v0.0.0-...-e39a43b Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TrueStrings  = []string{"1", "t", "true", "on", "y", "yes"}
	FalseStrings = []string{"0", "f", "false", "off", "n", "no"}
)

Functions

func B2s

func B2s(b []byte) string

B2s converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice header will change in the future go versions.

func BoolFromStr

func BoolFromStr(s string, def bool) bool

func HmacHex

func HmacHex(data, key []byte) string

HmacHex

func Md5Hex

func Md5Hex(str string) string

Md5Hex

func Md5HexShort

func Md5HexShort(str string) string

Md5HexShort

func NextNumberPowerOf2

func NextNumberPowerOf2(v uint64) uint64

*

  • NextNumberPowerOf2
  • returns the next nearest power of 2 for the given integer number
  • param: uint64 v
  • return: uint64

func RandomText

func RandomText(n int) string

func S2b

func S2b(s string) []byte

S2b converts string to a byte slice without memory allocation.

Note it may break if string and/or slice header will change in the future go versions.

func StrInSlice

func StrInSlice(a string, list []string) bool

StrInSlice returns a bool if the value in the slice Deprecated: Use sliceutil.In replace it

Types

This section is empty.

Jump to

Keyboard shortcuts

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