上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 55 下一页

2022年1月20日

golang map做排序后,md5加密

摘要: Go map字典排序后md5加密 package main import ( "bytes" "crypto/md5" "encoding/hex" "encoding/json" "fmt" "sort" "strings" ) func main() { params := make(map[s 阅读全文

posted @ 2022-01-20 14:22 星河赵 阅读(314) 评论(0) 推荐(0) 编辑

golang map与string的相互转换

摘要: map和json相互转换 MapToJson 为map转json. JsonToMap 为json为map package main import ( "encoding/json" "fmt" ) func MapToJson(param map[string]interface{}) strin 阅读全文

posted @ 2022-01-20 11:58 星河赵 阅读(2594) 评论(0) 推荐(0) 编辑

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 星河赵 阅读(4621) 评论(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 星河赵 阅读(36) 评论(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 星河赵 阅读(304) 评论(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 星河赵 阅读(1044) 评论(0) 推荐(0) 编辑

2021年12月22日

golang 系列:atomic 原子操作

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

posted @ 2021-12-22 15:59 星河赵 阅读(546) 评论(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 星河赵 阅读(43) 评论(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 星河赵 阅读(969) 评论(0) 推荐(0) 编辑

UUID简介及 Golang实现

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

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

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 55 下一页

导航