utils

package
v2.0.0-...-c4a6f3d Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LocalIP string
)

Functions

func AbsInt

func AbsInt(i int) int

func CheckError

func CheckError(action string, err error)

func ClientIP4

func ClientIP4() ([]byte, error)

func Compress

func Compress(raw []byte, compressLevel int) ([]byte, error)

func FakeIP

func FakeIP() []byte

func FileReadAll

func FileReadAll(path string) ([]byte, error)

func GetAddressByBytes

func GetAddressByBytes(data []byte) string

func HashString

func HashString(s string) int

HashString hashes a string to a unique hashcode.

func IsEmpty

func IsEmpty(s string) bool

func JavaFastJsonConvert

func JavaFastJsonConvert(fjsonStr string) string

JavaFastJsonConvert covert java fastjson for golang `{"brokerAddrTable":{"rocketmq-fce78b93-1":{"brokerAddrs":{0:"10.10.88.243:27622",2:"10.10.88.243:27328",3:"10.10.88.243:27664"},"brokerName":"rocketmq-fce78b93-1","cluster":"rocketmq-fce78b93"},"rocketmq-fce78b93-0":{"brokerAddrs":{0:"10.10.88.243:27562",2:"10.10.88.243:27565",3:"10.10.88.243:27902"},"brokerName":"rocketmq-fce78b93-0","cluster":"rocketmq-fce78b93"}},"clusterAddrTable":{"rocketmq-fce78b93":["rocketmq-fce78b93-1","rocketmq-fce78b93-0"]}}`

func MinInt

func MinInt(a, b int) int

func UnCompress

func UnCompress(data []byte) []byte

func WithoutNamespace

func WithoutNamespace(resource string) string

func WrapNamespace

func WrapNamespace(namespace, resourceWithOutNamespace string) string

func WriteToFile

func WriteToFile(path string, data []byte) error

Types

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet() Set

func (*Set) Add

func (s *Set) Add(v UniqueItem)

func (*Set) AddKV

func (s *Set) AddKV(k, v string)

func (*Set) Contains

func (s *Set) Contains(k string) (UniqueItem, bool)

func (*Set) Items

func (s *Set) Items() map[string]UniqueItem

func (*Set) Len

func (s *Set) Len() int

func (*Set) MarshalJSON

func (s *Set) MarshalJSON() ([]byte, error)

func (*Set) UnmarshalJSON

func (s *Set) UnmarshalJSON(data []byte) (err error)

type StringUnique

type StringUnique string

func (StringUnique) UniqueID

func (str StringUnique) UniqueID() string

type UniqueItem

type UniqueItem interface {
	UniqueID() string
}

Jump to

Keyboard shortcuts

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