随笔分类 - golang
摘要:Goland, 收费的,非常好用 https://www.jetbrains.com/go/ LiteIDE, 免费的,调试功能稍微不如 goland。
阅读全文
摘要:https://stackify.com/learn-go-tutorials/ What is Go Programming Language? Go, developed by Google in 2009, is a programming language that provides sup
阅读全文
摘要:https://groups.google.com/forum/#!topic/golang-nuts/I7a_3B8_9Gw https://groups.google.com/forum/#!msg/golang-nuts/coc6bAl2kPM/ypNLG3I4mk0J ask: Hello,
阅读全文
摘要:方法一: serialize 的标准方法: 使用gob 和 base64 或 base58。 方法二: 下面是自己实现的 serialize 方法,不推荐自己实现,应该用标准方法。 代码如下: 除了将数据放进结构体之外,你还可以直接将数据放进结构体对象的某个成员里: 不过要保证buffer与成员的内
阅读全文
摘要:https://github.com/takama/daemon https://github.com/immortal/immortal/blob/master/fork.go 这个是比较原始的最接近c语言的实现,它里面还有很多原始c语言的东西的golang实现:
阅读全文
摘要:在golang中,基本的channel读写操作都是阻塞的,如果你想要非阻塞的,可以使用如下示例: 即只要在select中加入default,阻塞立即变成非阻塞: 输出: 注意,golang无法kill 一个 goroutine,你 #只能# 通过一个channel给它发送消息让它退出,示例如下:
阅读全文
摘要:golang 中的 sizeof: 1: int(unsafe.Sizeof(uint32(0))) 2: int(reflect.TypeOf(uint32(0)).Size()) golang中的 union: 注意,如果你要以 (*B)(unsafe.Pointer(&a)) 这种方式来作为
阅读全文
摘要:https://groups.google.com/forum/#!topic/golang-nuts/JkvR4dQy9t4 https://golang.org/misc/cgo/gmp/gmp.go https://stackoverflow.com/questions/19910647/pa
阅读全文
摘要:https://go.googlesource.com/proposal/+/master/design/12416-cgo-pointers.md https://github.com/golang/go/issues/12416 Proposal: Rules for passing point
阅读全文
摘要:https://golang.org/misc/cgo/test/callback.go
阅读全文
摘要:interactive prompt library: abiosoft/ishell https://github.com/abiosoft/ishell Library for creating interactive cli applications. manifoldco/promptui
阅读全文
摘要:GOROOT golang安装路径。 GOPATH GOPATH可以设置多个工程目录,linux下用冒号分隔(必须用冒号,fish shell的空格分割会出错),windows下用分号分隔,但是go get 只会下载pkg到第一个目录,但是编译的时候会搜索所有的目录。 在fish shell下,使用
阅读全文
摘要:The channel is divided into two categories: unbuffered and buffered. (1) Unbuffered channelFor unbuffered channel, the sender will block on the channe
阅读全文
摘要:进行高进度运算的时候unint64已经无法满足需求,这个时候大家可以采用math.big库来进行高进度计算,下面以计算第10000位的菲波纳切数来展示big的用法,代码如下: package main import ( "fmt" "math/big" "time" ) const LIM = 10
阅读全文
摘要:将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
阅读全文
浙公网安备 33010602011771号