
go
江湖人称黑哥
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
go的交差编译
gox 是一个交叉编译的辅助工具,项目地址在 https://github.com/mitchellh/gox 使用 go get github.com/mitchellh/gox 进行安装后会在 $GOPATH/bin 目录下生成 gox.exe,为了方便以后使用,最好拷到 c:\go\bin 目录下。 然后进入到项目目录,执行 gox 即可一次性完成所有平台的编译。 $ gox Number...原创 2020-03-14 18:06:26 · 225 阅读 · 0 评论 -
gin结合go-redis根据ip完成访问频率限制
import ( "time" "github.com/go-redis/redis" ) // Limiter 定义属性 type Limiter struct { // Redis client connection. rc *redis.Client } // 根据redisURL创建新的limiter并返回 func NewLimiter(redisURL string) (...翻译 2020-02-29 11:52:51 · 3103 阅读 · 0 评论 -
gin统一返回 状态码
返回错误信息 func generateErrors(err error, key string) map[string][]string { if err == nil { return nil } if key == "" { key = "system" } if vErr, ok := err.(service.ValidateErrors); ok { ret...原创 2020-03-05 10:45:39 · 2591 阅读 · 0 评论 -
gin解决CORS跨域问题
package main import ( "time" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func main() { router := gin.Default() // CORS for https://foo.com and https://github.com origins, allowi...原创 2020-03-04 16:50:14 · 5788 阅读 · 0 评论