utils

package
v0.0.1-bula10 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 138

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachRange added in v0.4.39

func ForEachRange(totalSize int, maxSubRangeSize int, handler func(from, to int) error) error

ForEachRange is simple utility calling given function for each sub-range defined within [0-totalSize]. It wont be called however if range is empty. For example, MakeRanges(35, 10, fc) will result in fc being called 4 times with arguments: * 0-10 * 10-20 * 20-30 * 30-35 It can be used to split slice into smaller ones. Params totalSize must not be less than 0, maxSubRangeSize must be bigger than 0. If those are not met, function panics. If given function returns error, iteration stops and ForEachRange returns that error

func GetFieldTypeForOneOf added in v0.9.2

func GetFieldTypeForOneOf(protoMsg proto.Message, fieldDesc preflect.FieldDescriptor) (reflect.StructField, bool)

func GetValueFromProtoPath added in v1.0.0

func GetValueFromProtoPath(msg proto.Message, rawPath string) (interface{}, bool)

func GetValuesFromProtoPath added in v1.0.4

func GetValuesFromProtoPath(msg proto.Message, rawPath string) ([]interface{}, bool, error)

func IsNil

func IsNil(v interface{}) bool

func JsonMarshal

func JsonMarshal(v interface{}) ([]byte, error)

func SetFieldPathValueToProtoMsg added in v1.0.0

func SetFieldPathValueToProtoMsg(target proto.Message, rawPath string, v any)

func SetFieldValueToProtoMsg added in v1.0.0

func SetFieldValueToProtoMsg(target proto.Message, fieldDesc preflect.FieldDescriptor, v any)

func ToProtoCase added in v1.5.13

func ToProtoCase(name string) string

ToProtoCase Converts name to proto convention (replacing capital letters with _ and lowercase letter). No special treatment for digits.

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