04 2018 档案
摘要:将cobra下载到 $GOPATH,用命令: 然后使用 go install github.com/spf13/cobra/cobra, 安装后在 $GOBIN 下出现了cobra 可执行程序。如果你没有配置 $GOBIN,那么可以在$GOPATH/bin 下找到 cobra的可执行软件。 cobr
阅读全文
摘要:Golang单元测试对文件名和方法名,参数都有很严格的要求。 例如: 1、文件名必须以xx_test.go命名 2、方法必须是Test[^a-z]开头(T必须大写),func TestXxx (t *testing.T),Xxx部分可以为任意的字母数字的组合,但是首字母不能是小写字母[a-z],例如
阅读全文
摘要:golang没有 '%u' 点位符,若整数为无符号类型,默认就会被打印成无符号的。 宽度与精度的控制格式以Unicode码点为单位。宽度为该数值占用区域的最小宽度;精度为小数点之后的位数。操作数的类型为int时,宽度与精度都可用字符 '*' 表示。 对于 %g/%G 而言,精度为所有数字的总数,例如
阅读全文
摘要:转自: https://tonybai.com/2015/09/17/7-things-you-may-not-pay-attation-to-in-go/ Go以简洁著称,但简洁中不乏值得玩味的小细节。这些小细节不如goroutine、interface和channel那样"高大上","屌 丝"得
阅读全文
摘要:andlabs/ui已经重写,稳定性增强,但是组件很少,只提供了几种基础的控件,慎用。gxui死了,别用。linuxdeepin转QT了,所以…… windows系统最好的选择是walk。 首先,写windows客户端,就用walk!不要纠结其他的了,这是最好的选择!没有之一。 写Linux客户端,
阅读全文
摘要:1、golang链接c静态库的方法可以见这个示例: https://github.com/atercattus/go-static-link-example https://github.com/shadowmint/go-static-linking https://github.com/Alek
阅读全文
摘要:下面这两种方法都需要手动删除package的源码目录。 1、手动删除 It's safe to just delete the source directory and compiled package file. Find the source directory under $GOPATH/sr
阅读全文
摘要:GOPATH可以设置多个工程目录,linux下用冒号分隔(必须用冒号,fish shell的空格分割会出错),windows下用分号分隔,但是go get 只会下载pkg到第一个目录,但是编译的时候会搜索所有的目录。 在fish shell下,使用 set -x GOPATH "PATH1:PATH
阅读全文
摘要:go tool vet是你的好朋友,不要忽视它。 vet是一个优雅的工具,每个Go开发者都要知道并会使用它。它会做代码静态检查发现可能的bug或者可疑的构造。vet是Go tool套件的一部分,我们会在以后的文章中详细描述tool套件。它和go编译器一起发布,这意味着它不需要额外的依赖,可以很方便地
阅读全文
摘要:介绍 不论是开发Java还是你正在学习的Golang,都会遇到依赖管理问题。Java有牛逼轰轰的Maven和Gradle。 Golang亦有godep、govendor、glide、gvt、gopack等等,本文主要给大家介绍gilde。 glide是Golang的包管理工具,是为了解决Golang
阅读全文
摘要:Vendor目录介绍 随着Go 1.5 release版本的发布,vendor目录被添加到除了GOPATH和GOROOT之外的依赖目录查找的解决方案。在Go 1.6之前,你需要手动的设置环境变量GO15VENDOREXPERIMENT=1才可以使Go找到Vendor目录,然而在Go 1.6之后,这个
阅读全文
摘要:https://blog.golang.org/context Introduction In Go servers, each incoming request is handled in its own goroutine. Request handlers often start additi
阅读全文
摘要:https://github.com/avelino/awesome-go https://github.com/spf13/cobra # A Commander for modern Go CLI interactions https://github.com/lxn/walk # A Wind
阅读全文
摘要:https://github.com/minio/c2goasm http://microapl.com/asm2c/index.html 收费的 https://github.com/xlab/c-for-go c转golang https://github.com/xlab/android-go
阅读全文
摘要:Simple error handling primitives: https://github.com/pkg/errors Defer, Panic, and Recover: https://blog.golang.org/defer-panic-and-recover golang的defe
阅读全文
摘要:https://blog.golang.org/pipelines https://www.cnblogs.com/junneyang/p/6215785.html 简介 Go语言的并发原语允许开发者以类似于 Unix Pipe 的方式构建数据流水线 (data pipelines),数据流水线能够
阅读全文
摘要:An Old Hope Theme (theme, 推荐,且推荐它的 classic theme,安装后在颜色选项里选择,该插件的定制见文末) Cobalt2 (theme) Dracula for Visual Studio Code (theme) markdownlint Go for Vis
阅读全文
摘要:visual studio code (vsc) 对开发c,c++,node.js,javascript,python,html,golang,及撰写markdown等比较友好,同时支持git浏览及分屏对比,运行速度快,所以是值得一用的编辑器。 vscode阅读c和c++代码的插件clangd cl
阅读全文
摘要:http://www.jerf.org/iri/post/2917 Sum Types in Go posted Jun 02, 2013 in Programming, Golang, Haskell A couple of months back, I analyzed whether I wa
阅读全文
摘要:抑制幽门螺旋杆菌: 1、西兰花 鲜嫩的西兰花蔬菜,含有一种物质叫异硫氰酸酯,这种物质就是幽门螺杆菌的 " 天敌 ",可达到百分百抑制的作用,甚至还有医生给了它一个最强天然抗生素的称号,所以在食用的时候要选择鲜嫩的。研究发现,每天吃西兰花者肠道中幽门螺杆菌抗原水平可下降 40%。建议在食用的时候,将西
阅读全文
摘要:https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs https://studygolang.com/articles/2729 Go 程序的性能调试问题 假设你手上
阅读全文