前言
Google官方在2022.11.23重磅发布了Go语言编码规范。
这个编码规范源自于Google内部的Go项目,是Google的开发人员要遵守的代码规范。
在Go语言诞生后,全世界的Go开发者其实一直期盼着能有官方的编码规范,但迟迟未能如愿。
有些技术团队根据自己原来的编程语言背景,直接照搬过来,用于公司内部的Go语言编码规范。
尤其是写Java的,把Java的编程语言规范用于Go语言是非常不合适的。
为了让Go开发者可以知道如何写出更简洁、更地道的Go代码,官方也做出了一些努力,推出了Effective Go和Go Code Review Comments。
-
Go官方的Effective Go: https://go.dev/doc/effective_go。
Note added January, 2022: This document was written for Go’s release in 2009, and has not been updated significantly since. Although it is a good guide to understand how to use the language itself, thanks to the stability of the language, it says little about the libraries and nothing about significant changes to the Go ecosystem since it was written, such as the build system, testing, modules, and polymorphism. There are no plans to update it, as so much has happened and a large and gro