go
yylの博客
这个作者很懒,什么都没留下…
展开
-
Golang生成同时包含数字字母的随机字符串
package main import ( "fmt" "math/rand" "time" "regexp") // 随机生成指定位数的大写字母和数字的组合func GetRandomString(l int) string { str := "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ" bytes := []byte(str) result := []byte{} r := rand.New(rand.NewSource(ti.原创 2022-05-18 18:08:02 · 840 阅读 · 0 评论 -
golang正序与倒序-排序
type Docker struct { Name string `json:"name" binding:"required"` Version string `json:"version" binding:"required"` State string `json:"status"` CreateTime int64 `json:"createTime"` ContainerId string `json:"containerId"`原创 2021-09-01 10:43:06 · 1204 阅读 · 0 评论 -
GO 日志配置
Go 日志配置package loggerimport ( "fmt" "os" "path/filepath" "runtime" "strings" "time" "github.com/sirupsen/logrus")// 日志级别对应关系var loglevelmap = map[string]logrus.Level{ "panic": logrus.PanicLevel, "fatal": logrus.FatalLevel, "error": logrus原创 2021-07-05 19:18:55 · 243 阅读 · 0 评论 -
GO mongodb操作
GO mongodb1-封装单例连接package driverimport ( "context" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref")// MongoConnMgr mongodb连接管理type MongoConnMgr struct { Database *m原创 2021-07-05 18:54:57 · 132 阅读 · 0 评论 -
Goland开发环境配置
Goland开发环境配置文章目录Goland开发环境配置1-新建环境go文件夹2-修改Goland配置3-初始化项目4-下载使用安装包5-启动项目1-新建环境go文件夹mkdir ~/go_env2-修改Goland配置3-初始化项目# 新建一个项目(会出现一个mod文件,go的包管理工具)mkdir new_go_projectcd new_go_projectgo mod init new_go_project4-下载使用安装包# 下载第三方拓展包go get -u g原创 2021-05-19 15:12:02 · 1625 阅读 · 0 评论