Monthly Archives: August 2020

Helm install

This guide shows how to install the Helm CLI. Helm can be installed either from source, or from pre-built binary releases. From The Helm Project The Helm project provides two ways to fetch and install Helm. These are the official methods to get Helm... Read More | Share it now!


Kubernetes secrets by example You don’t want sensitive information such as a database password or an API key kept around in clear text. Secrets provide you with a mechanism to use such information in a safe and reliable way with the following... Read More | Share it now!

Cross-Compiling Golang …

Compiling your go code into a binary is pretty simple: This will build the binary for your current OS and architecture. But compiling binaries for other operating systems and even architectures is also possible. You just need to modify a few... Read More | Share it now!

golang解析json格式 — 全

项目中客户端和服务端的交互数据部分为json,因此在服务端就得解析,复杂的json解析起来其实还是挺费劲的。 交互的数据类似如下格式: 需要将json格式中的w字段取出来,并且拼成结果串进行展示 从json数组中获取ws ws是数组,数组元素为object cw是数组,数组元素为object w是string 从cw遍历获取w字段 初步实现如下: 这样实现,一层一层去转换类型,再去获取元素有点麻烦。既然是已知的json数据结构,那么可以定义好结构体,再去进行解析。 注意定义的时候变量名第一个字母要大写,也可以使用工具来自动生成定义;用工具生成的挺漂亮: 上面的元素有json:"sn"强制说明,因此如果只需获取对应的元素,其他元素不定义也是可以的。另外还有一种数据就是数组当中的元素还是数组,并且最后数组包含的是number或者string类型,需要再重写一个函数才行,数据如下,获取当中的元素 搜索到一段代码如下,重新实现了UnmarshalJSON ... Read More | Share it now!