上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 60 下一页

2022年1月7日

Go 将interface转为int, string, slice, struct等类型

摘要: 在golang中,interface{}允许接纳任意值,int, string, struct,slice等,因此我可以很简单的将值传递到interface{} 但是当我们将任意类型传入到test函数中转为interface后,经常需要进行一系列操作interface不具备的方法(即传入的User结 阅读全文

posted @ 2022-01-07 10:21 星河赵 阅读(5503) 评论(0) 推荐(0)

2022年1月6日

Go 指针相关操作

摘要: Go指针相关操作 输出结果456 //null_interface.go package main import "fmt" type Image2 struct { name string } func (I *Image2) SetName() { I.name = "123" } func m 阅读全文

posted @ 2022-01-06 18:45 星河赵 阅读(56) 评论(0) 推荐(0)

2021年12月30日

Supervisor 部署go gin服务 或在Linux下面独立部署

摘要: 一、Supervisor 部署方式 1. supervisord 安装 wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg sh setuptools-0.6c11-py2.7.egg 阅读全文

posted @ 2021-12-30 16:47 星河赵 阅读(414) 评论(0) 推荐(0)

2021年12月28日

go gin框架解析json

摘要: Gin框架踩坑——[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 200 这个报错场景为 : 1.Gin框架、2.编写POST请求方式接口、3.使用结构体绑定方式接 阅读全文

posted @ 2021-12-28 11:21 星河赵 阅读(1162) 评论(0) 推荐(0)

2021年12月22日

golang 系列:atomic 原子操作

摘要: sync/atomic 介绍 当我们想要对某个变量并发安全的修改,除了使用官方提供的 mutex,还可以使用 sync/atomic 包的原子操作,它能够保证对变量的读取或修改期间不被其他的协程所影响。 atomic 包的原子操作是通过 CPU 指令,也就是在硬件层次去实现的,性能较好,不需要像 m 阅读全文

posted @ 2021-12-22 15:59 星河赵 阅读(648) 评论(0) 推荐(0)

2021年12月20日

go 字符串操作相关

摘要: Go语言字符串相关操作 1. 判断字符串开头 package main import ( "fmt" "strings" ) func main() { myString := "www.topgoer.com" // Option 1: (Recommended) if strings.HasPr 阅读全文

posted @ 2021-12-20 14:41 星河赵 阅读(55) 评论(0) 推荐(0)

2021年12月17日

go 图片base64转二进制

摘要: go base64 二进制 互转 package main import ( "encoding/base64" "fmt" ) func main() { msg := "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgU 阅读全文

posted @ 2021-12-17 18:09 星河赵 阅读(1427) 评论(0) 推荐(0)

UUID简介及 Golang实现

摘要: go 实现uuid 简介 UUID 的目的是让分布式系统中的所有元素,都能有唯一的辨识信息,而不需要通过中心节点指定,无需考虑数据库创建时的名称重复问题。 目前最广泛应用的 UUID 是 RFC4122 协议规范的,有时 GUID 也特指是微软对标准 UUID 的实现,其实 RFC4122 的作者之 阅读全文

posted @ 2021-12-17 15:47 星河赵 阅读(1636) 评论(0) 推荐(0)

Go语言对字符串进行SHA1 哈希运算的方法

摘要: Go语言对字符串进行SHA1 哈希运算的方法 package main import ( "crypto/md5" "crypto/sha1" "fmt" "io" ) //对字符串进行MD5哈希 func a(data string) string { t := md5.New() io.Writ 阅读全文

posted @ 2021-12-17 15:39 星河赵 阅读(1284) 评论(0) 推荐(0)

Go - 获取当前时间 时间格式的转换 秒、毫秒、纳秒时间戳输出

摘要: 1. Go时间格式的转换 package main import ( "fmt" "time" ) func main() { t := time.Now() //2019-07-31 13:55:21.3410012 +0800 CST m=+0.006015601 fmt.Println(t.F 阅读全文

posted @ 2021-12-17 15:04 星河赵 阅读(5932) 评论(0) 推荐(0)

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 60 下一页

导航