西维蜀黍

【Protobuf】Protocol Buffers 入门

Protocol Buffers (Protobuf)

Protocol Buffers (Protobuf) is a free and open source cross-platform library used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.

The method involves an interface description language that describes the structure of some data and a program that generates source code from that description for generating or parsing a stream of bytes that represents the structured data.

  ...


【Golang】使用 - 上传文件

单文件上传

我们使用multipart/form-data格式上传文件,利用c.Request.FormFile解析文件。

// HandleUploadFile 上传单个文件
func HandleUploadFile(c *gin.Context) {
	file, header, err := c.Request.FormFile("file")
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"msg": "文件上传失败"})
		return
	}

	content, err := ioutil.ReadAll(file)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"msg": "文件读取失败"})
		return
	}

	fmt.Println(header.Filename)
	fmt.Println(string(content))
	c.JSON(http.StatusOK, gin.H{"msg": "上传成功"})
}
  ...


【Raspberry Pi】树莓派玩耍

查看树莓派系统的位数

安装软件的时候想查看树莓派系统是32位还是64位就出现了以下的操作,具体命令及作用如下:

getconf LONG_BIT        # 查看系统位数
uname -a            # kernel 版本
/opt/vc/bin/vcgencmd  version   # firmware版本
strings /boot/start.elf  |  grep VC_BUILD_ID    # firmware版本
cat /proc/version       # kernel
cat /etc/os-release     # OS版本资讯
cat /etc/issue          # Linux distro 版本
cat /etc/debian_version     # Debian版本编号

虽然树莓派3b的硬件支持64位的系统,但是官方的系统还是32位的,主要应该是为了兼容之前的硬件。

  ...


【Network】电信光猫内网穿透

Environmental Info

天翼网关-GPON,型号: PT921G

  ...


【Golang】使用 - Golang 使用 UUID

什么是 UUID?

UUID 是Universally Unique Identifier的缩写,即通用唯一识别码。

uuid的目的是让分布式系统中的所有元素,都能有唯一的辨识资讯,而不需要透过中央控制端来做辨识资讯的指定。如此一来,每个人都可以建立不与其它人冲突的 uuid。

A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems.

  ...