当前位置:网站首页>go 语言命名规范
go 语言命名规范
2022-07-02 03:45:00 【UPythonFish】
go 语言命名规范
一 变量定义规范
Go语言中的函数名、变量名、常量名、类型名、语句标号和包名等所有的命名,都遵循一个简单的命名规则:
一个名字必须以一个字母(Unicode字母)或下划线开头,后面可以跟任意数量的字母、数字或下划线
大写字母和小写字母是不同的:Name和name是两个不同的变量
关键字和保留字都不建议用作变量名
并且一个项目中有且只有一个main包,多了或者少了都不能运行。学习基础阶段,可以再一个项目下有多个main函数,但是必须以file形式运行,不能以包的形式运行。
// 变量定义推荐用驼峰体
-AgeOfPerson go语言和java语言推荐,python不推荐
-age_of_person 下划线方式,不推荐(go不推荐,python推荐)
// go文件的名字,建议使用下划线(参照源码)
-java语言中:变量和文件名都推荐用驼峰
-Python中:变量名和文件名都推荐用下划线
二 关键字与保留字
Go语言中关键字有25个;关键字不能用于自定义名字,只能再特定语法结构中使用。37个保留字,主要对应内建的常量、类型和函数
// 25个关键字
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
//37个保留字
内建常量: true false iota nil
内建类型: int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64 complex128 complex64
bool byte rune string error
内建函数: make len cap new append copy close delete
complex real imag
panic recover
边栏推荐
- FFMpeg AVFrame 的概念.
- 【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
- 《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
- Oracle的md5
- Suggestions on settlement solution of u standard contract position explosion
- Unity脚本的基础语法(7)-成员变量和实例化
- 蓝桥杯单片机省赛第十一届第二场
- Xlwings drawing
- 蓝桥杯单片机省赛第八届
- The 11th Blue Bridge Cup single chip microcomputer provincial competition
猜你喜欢

高性能 低功耗Cortex-A53核心板 | i.MX8M Mini

NLog使用

【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
![[personal notes] PHP common functions - custom functions](/img/3d/d50622e3ddb08f654f30063e8226ac.jpg)
[personal notes] PHP common functions - custom functions

Getting started with MQ

Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused

Influence of air resistance on the trajectory of table tennis

The second game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup

0 foundation how to learn automated testing? Follow these seven steps step by step and you will succeed

【DesignMode】原型模式(prototype pattern)
随机推荐
蓝桥杯单片机数码管技巧
High performance and low power cortex-a53 core board | i.mx8m Mini
Unity脚本的基础语法(8)-协同程序与销毁方法
Vite: configure IP access
Kotlin basic learning 14
JS generate random numbers
Blue Bridge Cup SCM digital tube skills
【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation
[tips] use Matlab GUI to read files in dialog mode
Failed to upgrade schema, error: “file does not exist
Oracle 常用SQL
Custom classloader that breaks parental delegation
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
微信小程序中 在xwml 中使用外部引入的 js进行判断计算
In wechat applet, the externally introduced JS is used in xwml for judgment and calculation
树莓派GPIO引脚控制红绿灯与轰鸣器
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
[untitled] basic operation of raspberry pie (2)