go语言的一些小功能实现
LionGod
新进青年大军,00领先者
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
grpc+gin+proto,使用http调用rpc接口
接下来重点讲如何创建并通过http 使用rpc接口 。 proto代码 syntax = "proto3"; package proto.web.web.proto; option go_package = "pb;pb"; // 进入 message ComeIn { string name = 1; // 名称 string trait = 2; // ip } // 离开 message GetOut { string name = 1; // 名称 string ip = 2; /原创 2020-07-02 18:22:10 · 3912 阅读 · 0 评论 -
go语言 实现 今天、昨天、本周、本月的时间
go语言内置time模块 improt ( "time" "fmt" ) func main() { now := time.Now() week := now.Weekday() offset := int(time.Monday-week) if offset > 0 { offset = -6 } fmt.Println(offset) //周 StartDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0,原创 2020-05-16 11:01:34 · 1545 阅读 · 0 评论 -
go语言 使用"regexp"实现纯中文识别、匹配
使用代码: package main import ( "fmt" "regexp" ) //本次匹配使用"regexp"内置的一个正则匹配包 func main() { str := "李小龙"//要匹配的字符串 isChinese := regexp.MustCompile("^[\u4e00-\u9fa5]")//我们要匹配中文的匹配规则 fmt.Println(isChinese.MatchString(str))//使用MatchString来将要匹配的字符串传到匹配规则中 } 运行结原创 2020-05-11 16:26:44 · 5597 阅读 · 0 评论
分享