util

package
v0.1.0-fix-1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TomlSettings = toml.Config{
	NormFieldName: func(rt reflect.Type, key string) string {
		return key
	},
	FieldToKey: func(rt reflect.Type, field string) string {
		return field
	},
	MissingField: func(rt reflect.Type, field string) error {
		link := ""
		if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" {
			link = fmt.Sprintf(", see https://pkg.go.dev/%s#%s for available fields", rt.PkgPath(), rt.Name())
		}
		_, _ = fmt.Fprintf(os.Stderr, "field '%s' is not defined in %s%s\n", field, rt.String(), link)
		return nil
	},
}

TomlSettings - These settings ensure that TOML keys use the same names as Go struct fields.

Functions

func BoolToInt

func BoolToInt(b bool) int

BoolToInt convert bool to int

func BytesSliceToString

func BytesSliceToString(bytes [][]byte) string

BytesSliceToString is used to serialize

func GenerateRequestID

func GenerateRequestID() string

GenerateRequestID is used to generate random requestID.

func GetIPFromGRPCContext

func GetIPFromGRPCContext(ctx context.Context) net.IP

GetIPFromGRPCContext returns a IP from grpc client

func JoinWithComma

func JoinWithComma(slice []string) string

JoinWithComma con vert string slice to one string with comma

func SplitByComma

func SplitByComma(str string) []string

SplitByComma split string by comma

func StringListToBytesSlice

func StringListToBytesSlice(stringList []string) [][]byte

StringListToBytesSlice is used to deserialize

func StringToBool

func StringToBool(str string) (bool, error)

StringToBool covert string to bool

func StringToBytesSlice

func StringToBytesSlice(str string) ([][]byte, error)

StringToBytesSlice is used to deserialize

func StringToInt32

func StringToInt32(str string) (int32, error)

StringToInt32 convert string to int32

func StringToInt64

func StringToInt64(str string) (int64, error)

StringToInt64 convert string to int64

func StringToUint32

func StringToUint32(str string) (uint32, error)

StringToUint32 covert string to uint32

func StringToUint64

func StringToUint64(str string) (uint64, error)

StringToUint64 convert string to uint64

func Uint32ToString

func Uint32ToString(u uint32) string

Uint32ToString convert uint32 to string

func Uint64ToString

func Uint64ToString(u uint64) string

Uint64ToString covert uint64 to string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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