Go语言中文网 为您找到相关结果 12

go proxy 设置

在Go 1.13中,我们可以通过GOPROXY来控制代理,以及通过GOPRIVATE控制私有库不走代理。 设置GOPROXY代理: go env -w GOPROXY=https://goproxy.cn,direct 设置GOPRIVATE来跳过私有库,比如常用的Gitlab或Gitee,中间使用逗号分隔: go env -w GOPRIVATE=*.gitlab.com,*.gitee.com 如果在运行go mod vendor时,提示Get https://sum.golang.org/lookup/xxxxxx: dial tcp 216.58.200.49:443: i/o timeout,则是因为Go 1.13设置了默认的GOSUMDB=sum.golang.org,这个网站是...阅读全文

博文 2019-10-09 18:32:46 aside section ._1OhGeD

gin-数据绑定+数据验证

将用户传来的参数和我们的绑定 type Login struct { User string `form:"name" json:"name" binding:"required"` //这里有做简单验证,表示参数是必须的 Age string `form:"age" json:"age" binding:"required"` } 绑定url查询参数到结构体,实质就是上一步获取到参数,然后新建一个结构体,这样在golang里面就可以用新的结构体来做操作了 r.Any("/test", func(c *gin.Context) { var persion Login if c.ShouldBindQuery(&persion) == nil { fmt.Println(persion.Use...阅读全文

博文 2019-10-12 13:32:58 aside section ._1OhGeD

golang中使用JWT验证

1.生成token并传给客户端:token :=jwt.NewWithClaims(jwt.SigningMethodHS256,jwt.MapClaims{"id":c.ID,"username":c.Username,"exp":time.Now().Unix() +60*10,"nbf":time.Now().Unix(),"iat":time.Now().Unix(),})tokenString,err =token.SignedString([]byte(secret))2.客户端验证:func Parse(tokenString string,secret string) (*Context,error) {ctx := &Context{}token,err :=jwt.Par...阅读全文

博文 2019-10-28 11:32:46 aside section._1OhGeD

在线sql转proto/struct等(GO在线工具集)

#### GO在线工具集: [let's go](https://www.lovestyle.top/toolweb) - 内容如下: 1.[在线sql处理](https://www.lovestyle.top/toolweb/#/home/sql2proto) 2.[在线json处理](https://www.lovestyle.top/toolweb/#/home/json2struct) 3.[在线加/解密](https://www.lovestyle.top/toolweb/#/home/md5) 4.[在线图片处理](https://www.lovestyle.top/toolweb/#/home/imgresi...阅读全文

golang 1.4 mod 使用经验

1.go mod 替代原来gopath的功能(可能理解有误) 2.go mod init 一个golang 项目 go mod 的命令使用 $ go help mod Usage: go mod [arguments] The commands are: download download modules to local cache edit edit go.mod from tools or scripts graph print module requirement graph init initialize new module in current directory tidy add missing and remove unused modules vend...阅读全文

博文 2020-03-01 03:32:47 perryn

GoLang生成不重复六位验证码

不同的整数生成固定六位的字符串验证码 package main import ( "container/list" "fmt" ) var baseStr string = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ" var base []byte = []byte(baseStr) func Base34(n uint64) []byte { quotient := n mod := uint64(0) l := list.New() for quotient != 0 { mod = quotient % 34 quotient = quotient / 34 l.PushFront(base[int(mod)]) } listLen := l.Len() ...阅读全文

go代理设置转载https://www.cnblogs.com/lijiejoy/p/11520944.html

在Go 1.13中,我们可以通过GOPROXY来控制代理,以及通过GOPRIVATE控制私有库不走代理。 设置GOPROXY代理: go env -w GOPROXY=https://goproxy.cn,direct 设置GOPRIVATE来跳过私有库,比如常用的Gitlab或Gitee,中间使用逗号分隔: go env -w GOPRIVATE=*.gitlab.com,*.gitee.com 如果在运行go mod vendor时,提示Get https://sum.golang.org/lookup/xxxxxx: dial tcp 216.58.200.49:443: i/o timeout,则是因为Go 1.13设置了默认的GOSUMDB=sum.golang.org,这个网站是...阅读全文

博文 2020-02-05 19:32:45 风洛神

golang 关于正则的使用

正则验证 package main import "regexp" func main(){ account:="dsddasda12" match,_:=regexp.MatchString(`^[a-z\d+]{6,15}$`,account) if match{ fmt.Println("ok") }else{ fmt.Println("fail") } } 正则取值 package main import "regexp" func main(){ account:="dsddasda12aaasa" reg:= regexp.MustCompile(`^([a-z]+).\d+.(\w+)`) attr:=reg.FindStringSubmatch(account) fmt.Pr...阅读全文

博文 2020-05-09 19:32:42 顶尖少爷