goutils

module
v0.0.0-...-cb1f643 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0

README

goutils

Penglai Utils golang version.

Download and install

go get -u github.com/youpenglai/goutils

Directory explain

  • 一个类别一个文件夹,文件夹里必含一个测试文件
  • 可以使用go test -v测试

Utils directorys

功能 包名 备注
命令行 cmd 调用系统命令行
类型转换 convert 数字/时间类型转换
加密解密 crypto base64、md5...多种加密解密
HTTP调用 http http快速调用
路径文件 path 当前路径、文件列表
protobuf protobuf 生成protobuf的go文件
随机数据 rand 获取随机数、uuid
系统信息 system 获取系统信息
token token 安全认证
参数效验 valid 参数效验

Directories

Path Synopsis
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md

Jump to

Keyboard shortcuts

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