xutils

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MulanPSL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSuccess = 0
	CodeError   = 1
	CodeUnLogin = 2
)
====================================================================== *
* 功能:Gin 响应函数封装
* ======================================================================

定义错误编码

Variables

View Source
var (
	ERR_NO_LOCAL_IP_FOUND = errors.New("没有找到网卡IP")
)

Functions

func CamelString

func CamelString(s string) string

====================================================================== * * 功能:蛇形转驼峰 * 描述:xx_yy to XxYx xx_y_y to XxYY * ======================================================================

func GetLocalIP added in v1.0.12

func GetLocalIP() (ipv4 string, err error)

获取本机网卡IP

func GetOutBoundIP added in v1.0.18

func GetOutBoundIP() (ip string, err error)

func MD5

func MD5(s string) string

============================================== * * 功能:MD5加密 不需要处理错误 * ==============================================

func Md5

func Md5(s string) (string, error)

============================================== * * 功能:MD5加密 需要处理错误 * ==============================================

func ResponseError

func ResponseError(ctx *gin.Context, err error)

func ResponseErrorCode

func ResponseErrorCode(ctx *gin.Context, errCode int, err error)

func ResponseSuccess

func ResponseSuccess(ctx *gin.Context, data interface{})

func SnakeString

func SnakeString(s string) string

====================================================================== * * 功能:驼峰转蛇形 snake string * 描述:XxYy to xx_yy , XxYY to xx_y_y * ======================================================================

func StrucAssignFilter

func StrucAssignFilter(a interface{}, b interface{}, fields ...string) (err error)

============================================== * * 功能:实现两个结构体复制字段 * 用b的所有字段覆盖a的 * 如果fields不为空, 表示用b的特定字段覆盖a的 * a应该为结构体指针 * ==============================================

func StructAssign

func StructAssign(target interface{}, source interface{})

============================================== * * 功能:实现两个结构体复制字段 在要修改的结构体中查询有数据结构体中相同属性的字段,有则修改其值 * target 要修改的结构体 * source 有数据的结构体 * ==============================================

Types

type Response

type Response struct {
	ErrorCode int         `json:"code"`
	Msg       string      `json:"message"`
	Data      interface{} `json:"data"`
	TraceId   interface{} `json:"trace_id"`
	Stack     interface{} `json:"stack"`
}

Jump to

Keyboard shortcuts

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