随笔分类 -  go

摘要:https://blog.csdn.net/raogeeg/article/details/86743953 @Title 这个 API 所表达的含义,是一个文本,空格之后的内容全部解析为 title @Description这个 API 详细的描述,是一个文本,空格之后的内容全部解析为 Descr 阅读全文
posted @ 2019-07-04 11:39 wujf 阅读(761) 评论(0) 推荐(0) 编辑
摘要:改为支持beego,要修改一下table2Struct.go文件的295行和299行,添加column() 阅读全文
posted @ 2019-06-17 16:21 wujf 阅读(3388) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "sync" ) type object interface{} type Set struct { m map[object]bool sync.RWMutex //线程安全实现,记录下 } //初始化 func New() *Set { return &Set{ m: map... 阅读全文
posted @ 2019-05-17 17:18 wujf 阅读(866) 评论(0) 推荐(0) 编辑
摘要:方式一 方式二 阅读全文
posted @ 2019-05-17 16:19 wujf 阅读(6078) 评论(0) 推荐(0) 编辑
摘要:package main import ( "fmt" "math/rand" ) func main() { ch := make(chan int) done := make(chan bool) f := make(chan bool) go func() { for { select { ... 阅读全文
posted @ 2019-05-17 16:17 wujf 阅读(515) 评论(0) 推荐(0) 编辑
摘要:func selects() { db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local") checkErr(err) // 查询数据 //查询数据,取所有字段 rows2, _ := db.Query("... 阅读全文
posted @ 2019-04-15 10:53 wujf 阅读(1778) 评论(0) 推荐(0) 编辑
摘要:"github.com/satori/go.uuid" uid, _ := uuid.NewV4()放在gin的context里玩耍 //c.Set("uuid", uid)//应用里面打日志//uid,_:= c.Get("uuid") 阅读全文
posted @ 2019-04-13 14:23 wujf 阅读(3351) 评论(0) 推荐(0) 编辑
摘要:打window包直接go build一下,完事, 但是,打linux包出现如下错误 ..\github.com\mattn\go-isatty\isatty_linux.go:7:8: cannot find package "golang.org/x/sys/unix" in any of: 解决 阅读全文
posted @ 2019-04-13 11:24 wujf 阅读(1286) 评论(0) 推荐(0) 编辑
摘要:func Cors(c *gin.Context) { c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token") c.Header("... 阅读全文
posted @ 2019-04-13 10:52 wujf 阅读(473) 评论(0) 推荐(0) 编辑
摘要:1、定义中间件 2、对要拦截的路由进行分组并引入中间件 3、测试 分别查看http://127.0.0.1:8088/api/ping和http://127.0.0.1:8088/ping,可以看出一个会输出“我是中间件”,一个不会输出 4、结论 什么权限、登陆、token之类的就这样起飞吧 阅读全文
posted @ 2019-04-13 10:47 wujf 阅读(1457) 评论(0) 推荐(0) 编辑
摘要:func wrapCtx(handler func(ctx *gin.Context)) gin.HandlerFunc { return func(c *gin.Context) { //获取请求的url log.Info("当前请求url:%s", c.Request.RequestURI) t 阅读全文
posted @ 2019-04-13 10:23 wujf 阅读(775) 评论(0) 推荐(0) 编辑
摘要:需求: 记录所有请求的json数据 此方法即可打印所有请求的body内容,但是在对应的处理器上就取不到数据 解决办法: 阅读全文
posted @ 2019-04-12 19:01 wujf 阅读(13273) 评论(0) 推荐(0) 编辑
摘要:导包 加载log4go 写日志 java折腾久了,日志框架还是喜欢这个 阅读全文
posted @ 2019-04-12 14:46 wujf 阅读(870) 评论(0) 推荐(0) 编辑
摘要:func getCurrentPath() string { _, filename, _, ok := runtime.Caller(1) var cwdPath string if ok { cwdPath = path.Join(path.Dir(filename), "") // the the main function file directo... 阅读全文
posted @ 2019-04-12 14:42 wujf 阅读(1340) 评论(0) 推荐(0) 编辑
摘要:set GOARCH=amd64 set GOOS=linux go build xx.go 会生成一个没有后缀的xx二进制文件 将该文件放入linux系统某个文件夹下 赋予权限 chmod 777 xx 执行 ./xx 阅读全文
posted @ 2019-02-27 14:17 wujf 阅读(5808) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示