Google重磅发布Go语言编码规范

Google在2022年11月23日发布了Go语言编码规范,源自其内部项目,填补了Go开发者期待已久的官方规范空白。Effective Go和Code Review Comments提供了一些指导,但不全面。此次发布的规范包括Style Guide、Style Decisions和Best Practices,覆盖了通用规则、具体编码决策和最佳实践。例如,推荐使用全小写的package命名,避免使用下划线或驼峰命名。同时,Receiver命名应简短,为类型名缩写并保持一致性。规范开源在GitHub,有兴趣的读者可以进一步了解。
摘要由CSDN通过智能技术生成

前言

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值