Saki's 研究记录

go mod: disallowed version string
问题通过go get拉取公司私有包的时候报错:invalid: disallowed version string,但master、develop分支则可以正常拉取。有问题的分支名为feature/xxxx,现象: 12go get -u gitlab.xxxx.com/xxxx@feature/xxxxgo get: gitlab.xxxx.com/xxxx@feature/xxxx: invalid version: version "feature/XXXX" invalid: disallowed version string 解决问题的关键在分支名称中的&...
golang调用etcdv3报错undefined
问题最近准备使用Etcd开发一些分布式的应用,结果第一步就翻车了。当信心满满的使用go mod开始go mod tidy时etcdv3有报错: 123456# github.com/coreos/etcd/clientv3/balancer/pickerundefined: balancer.PickOptionsundefined: balancer.PickOptions# github.com/coreos/etcd/clientv3/balancer/resolver/endpointundefined: resolver.BuildOptionundefined: resolv...
go generate报错io/fs: package io/fs is not in GOROOT
现象执行 go generate 出错: 12github.com/flipped-aurora/gin-vue-admin/server/utils/plugin importsio/fs: package io/fs is not in GOROOT (/usr/local/Cellar/go/1.15.3/libexec/src/io/fs) 原因golang 版本太旧,需要升级 解决办法升级 golang 版本, 可参考yum 安装/更新 golang
golang 关于函数的返回值问题
函数返回值的一些实践 123456789101112131415type Mystruct struct{ Val int}func myfunc() Mystruct{ return Mystruct{Val:1}}func myfunc() *MyStruct { return &MyStruct{}}func myfunc(s *MyStruct) { s.Val = 1} 三种方式的不同点: 第一个返回 struct 的 co...
减小 golang 编译出的程序体积
安装 upx1234# CentOSyum install -y upx# Macbrew install upx 进行压缩参数 -o 指定压缩后的文件名; -9 指定压缩级别,1-9。 12345678910upx -9 -o gin_admin_empty_upx gin_admin_emptyUltimate Packer for eXecutables Copyright (C) 1996 - 2020UPX 3.96 Markus Oberhumer, Laszlo Molnar & John Reise...
yum install/update golang
InstallInstall EPEL package by using yum install epel-release command: 1yum install -y epel-release Update your system: 1yum update Install Golang using yum: 1yum install -y golang Check Golang version: 12go versiongo version go1.15.14 linux/amd64 UpdateUnless someone either adds Go 1.7+ to a...