随笔分类 -  Go

Go语言学习笔记
摘要:# Intellij project files *.iml *.ipr *.iws .idea/ # go.gitignore from https://github.com/github/gitignore/blob/master/Go.gitignore # Binaries for prog 阅读全文
posted @ 2020-11-25 09:54 飞天小烤猪
摘要:apt安装 apt install golang-goprotobuf-dev 手动安装 wget https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.zip unzip, 阅读全文
posted @ 2020-10-24 10:09 飞天小烤猪
摘要:import ( "time" _ "github.com/go-sql-driver/mysql" ) type User struct { Id int Uuid string Name string Email string Password string CreatedAt time.Tim 阅读全文
posted @ 2020-09-15 17:33 飞天小烤猪
摘要:阿里云ECS Ubuntu18 部署单节点etcd方法 安装 安装etcd 有两种方法安装,第一种使用apt,第二种从github下载编译好的二进制文件,我使用的是第二种。 我下的是3.3的最后一个版本。 mv /tmp/etcd-download-test/etcd /usr/local/bin/ 阅读全文
posted @ 2020-06-04 22:29 飞天小烤猪
摘要:Go etcd client使用时在go module下同步失败解决方法 之前没见过go mod 出现找不到undefined的问题,以为是代理不行,换了代理还是解决不了。 问题原因:gRPC版本问题 gRPC版本 最新的是1.29,这个版本太新,要换一个版本。 解决 修改 gRPC版本为1.26 阅读全文
posted @ 2020-06-04 17:50 飞天小烤猪
摘要:Review:Go语言sync包和并发控制 来源: []: https://mp.weixin.qq.com/s?__biz=MzAxMTA4Njc0OQ==&mid=2651439459&idx=3&sn=b8fcbcc73a4c8a527daa48a7a585ad19&chksm=80bb1f9 阅读全文
posted @ 2020-05-29 10:37 飞天小烤猪
摘要:主要参考文章 [https://segmentfault.com/a/1190000012978989]: Go的字符串连接的几种方法和优化 运算符+ Go和Java一样,string是不可变的,因此频繁使用+性能不好。 bytes.buffer 相当于Java的StringBuffer,用法类似。 阅读全文
posted @ 2020-05-25 19:17 飞天小烤猪
摘要:Go的文件读写几种方法 整个文件:ioutil 文件指针:Open+Read+Write 带缓存IO:bufio 阅读全文
posted @ 2020-05-25 18:07 飞天小烤猪
摘要:sort.Slice声明 实际使用 和C++的sort模板类似,只需要实现less函数,Go特别的是传入的函数不是直接传入less,而是一个匿名函数,匿名函数的参数是两个下标,表示两个比较元素在切片中的下标 阅读全文
posted @ 2019-12-31 11:22 飞天小烤猪
摘要:准备依赖 测试HelloWorld 打开server $env:GOPATH\src\github.com\grpc\grpc go\examples\helloworld\greeter_server go run main.go 打开client $env:GOPATH\src\github.c 阅读全文
posted @ 2019-12-15 17:27 飞天小烤猪
摘要:使用git # 吧$GOPATH替换成自己的GOPATH git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net git clone https://github.com/golang/text.git $GO 阅读全文
posted @ 2019-12-15 17:20 飞天小烤猪
摘要:Go module的两个代理源 阿里云 https://mirrors.aliyun.com/goproxy/ 使用帮助 1.使用go1.11以上版本并开启go module机制 2.导出GOPROXY环境变量 export GOPROXY=https://mirrors.aliyun.com/go 阅读全文
posted @ 2019-12-09 18:15 飞天小烤猪