描述 strings.HasPrefix函数用来检测字符串是否以指定的前缀开头。 语法 需要导入 strings包 strings.Hasprefix(s, prefix) 参数 参数 说明 备注 s 待检测的字符串 字符串类型的参数 prefix 指定的...
go
GORM对实现datetime和date类型时间
model 定义 type Plan struct { Id int `gorm:"primary_key"` Title string `gorm:"column:title;not null;size:128"` Start time.Time `gorm:"type:date;column:start"` End time.Tim...
golang 前补0
func StrPad( str int64, index int) string { ending := strconv.FormatInt(str, 10) switch { case len(ending) index: return fmt.Sprintf("%."+fmt.Sprintf("%vs", index), ending[len(ending)-...
Golang如何获取当前年份月份日
众所周知Golang的时间格式化很奇葩 date := time.Now().Format("2006-01-02 15:04:05") 只有写以上参数才可获得对应的时间格式,所以我们也可以利用这个方法获取当前时间的年月日时分秒 year:=time....
mac上brew安装grpc
grpc安装 brew install grpc brew install protobuf brew install protoc-gen-go brew install protoc-gen-go-grpc 检查: go-version protoc --version protoc-gen-go --version 安装...
casbin的表字段解释
casbin_rule表中 p_type --类型,可以是p策略,g角色等等 v0 --角色 roleName/roleId sub v1 --Path 路径 obj v2 --Method 请求方式 act v3 --允许读/写 read/write ...
Goland配置goproxy.cn代理
打开Goland软件,可以看到如下菜单。 选中File菜单,在弹出的菜单列表中,选中Settings选项。进入Settings界面 注意上图圈起来的两处: 1、勾选Enable Go Modules integration.(必须) 2、设置...
golang 嵌套结构体属性为null
最近写了一个go的项目,嵌套了多层结构体,返回值无法处理成null很不利于客户端调试 最终在不懈努力下找到了解决方案 定义结构体 type UserList struct { CID int `json:"c_id"` CName stri...
go 驼峰下划线互转
import ( "strings" "unicode" ) /** * @Author QY * @Email 80013593@qq.com * @Description //字符串首字母小写 * @Date 11:28 2023/2/5 * @Param * @return *...
golang的bytes.buffe
一、创建缓冲期 bytes.buffer是一个缓冲byte类型的缓冲器 1、使用bytes.NewBuffer创建:参数是[]byte的话,缓冲器里就是这个slice的内容;如果参数是nil的话,就是创建一个空的缓冲器。 2、bytes.NewBufferS...