随笔分类 -  go

go语言
摘要:本测试旨在测试md5编码之后的数据hash随机性,以验证ZCache各节点数据分布的均匀性 测试代码如下 阅读全文
posted @ 2018-12-17 19:28 一沐春风 阅读(1005) 评论(0) 推荐(0)
摘要:转载自https://www.cnblogs.com/reflectsky/p/golang-gob-struct.html golang可以通过json或gob来序列化struct对象,虽然json的序列化更为通用,但利用gob编码可以实现json所不能支持的struct的方法序列化,利用gob包 阅读全文
posted @ 2018-12-17 09:57 一沐春风 阅读(1164) 评论(0) 推荐(0)
摘要:转载自 https://www.cnblogs.com/luckcs/articles/4107647.html 作者:John Graham-Cumming. 原文点击此处。翻译:Lubia Yang(已失效) 前些天我介绍了我们对Lua的使用,implement our new Web Appl 阅读全文
posted @ 2018-12-14 10:07 一沐春风 阅读(886) 评论(0) 推荐(0)
摘要:package main import ( "fmt" ) func main() { msg := "{Amount:21111111 DrawalBankHolder:刘成友 DrawalBankNo:6212264100011335366 DrawalSn:5112118111111690 DrawalTime:2018-11-30T00:00:00+08:00 Fin... 阅读全文
posted @ 2018-12-13 16:21 一沐春风 阅读(1681) 评论(0) 推荐(0)
摘要:golang读写锁,其特征在于 读写锁共有四个方法 使用例子如下 阅读全文
posted @ 2018-12-11 19:10 一沐春风 阅读(5409) 评论(0) 推荐(0)
摘要:1、version: 查看golang版本 例:go version 2、run: 编译并运行go程序 例: go run main.go 3、build: 编译go程序,不允许 例:go build main.go4、vet: 静态检查 例:go tool vet . //静态检查当前目录下所有文 阅读全文
posted @ 2018-12-10 16:01 一沐春风 阅读(3275) 评论(0) 推荐(0)
摘要:import ( "github.com/gin-gonic/gin" "net/http" "github.com/sirupsen/logrus" ) // 1、最简单gin func GinSample(){ engine := gin.Default() engine.Any("/",func(context *gin.Context){ ... 阅读全文
posted @ 2018-12-10 15:46 一沐春风 阅读(955) 评论(0) 推荐(0)
摘要:// 代码转载自https://blog.csdn.net/qq_36183935/article/details/80315808, 向原作者致谢 package main import "fmt" type AVL struct { value int //值 height int //深度 left *AVL //左子树 right *AVL... 阅读全文
posted @ 2018-12-10 15:44 一沐春风 阅读(369) 评论(0) 推荐(0)
摘要:// 1.多goroutine间通信,channel使用 import ( "fmt" "math/rand" "net" "os" "os/signal" "time" "crypto/sha256" "crypto/sha1" "crypto/md5" "strings" ) func Producer(que... 阅读全文
posted @ 2018-12-10 15:41 一沐春风 阅读(331) 评论(0) 推荐(0)
摘要:import ( "fmt" "os" "strconv" "time" ) func main() { timeArray := []string{} idx := 0 for _ ,arg := range os.Args{ if idx ==0 { idx = 1 c... 阅读全文
posted @ 2018-12-10 15:39 一沐春风 阅读(942) 评论(0) 推荐(0)
摘要:1、运行程序报runnerw.exe: CreateProcess failed with error 216 (no message available) 错误原因:当前包不是main 2、defer用法 阅读全文
posted @ 2018-12-10 15:32 一沐春风 阅读(409) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "sync" ) func print(idx int, wg *sync.WaitGroup) { fmt.Printf("index %d: \n", idx) wg.Done() } func main() { var wg sync.WaitGroup for i := 0; i... 阅读全文
posted @ 2018-12-04 10:08 一沐春风 阅读(123) 评论(0) 推荐(0)
摘要:package main import "fmt" func main(){ fmt.Println("hello world") } 阅读全文
posted @ 2018-12-04 09:29 一沐春风 阅读(120) 评论(0) 推荐(0)