utils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPrefix

func AddPrefix(origin string, prefixs []string) string

AddPrefix add prefix to origin string, use delimiter :

func Get

func Get(url string) (resp []byte, err error)

Get 发送一个 GET 请求到指定的 URL,并返回响应体

func GetCallerInfo

func GetCallerInfo(skip int) string

func IsAllBlank

func IsAllBlank(args ...interface{}) bool

IsAllBlank args type only string/[]byte

func IsAnyBlank

func IsAnyBlank(args ...interface{}) bool

IsAnyBlank args type only string/[]byte

func MarshalSorted

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

MarshalSorted 自定义Marshal函数,用于生成按键排序的JSON字符串,只适用于结构体,基本数据类型或切片不行 @Description: json.Marshal加密map时会进行排序,因此只需将结构体转换成map即可,此方法使用先序列化为JSON,再解析JSON到map @param v @return []byte @return error

func MarshalSortedFast

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

MarshalSortedFast 自定义Marshal函数,用于生成按键排序的JSON字符串,只适用于结构体,基本数据类型或切片不行 @Description: 此方法使用了反射转换到map,性能更快,但是对JSON tag支持不够完善 @param v @return []byte @return error

func Post

func Post(url string, body []byte, header map[string]string) (resp []byte, err error)

Post 发送一个 POST json 请求到指定的 URL,使用提供的 body,并返回响应体

func ToCamelCase

func ToCamelCase(field string) string

ToCamelCase as: abc_def -> AbcDef

Types

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
}

Logger define log interface

Jump to

Keyboard shortcuts

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