当前位置:网站首页>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
边栏推荐
- Failed to upgrade schema, error: “file does not exist
- Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
- 近段时间天气暴热,所以采集北上广深去年天气数据,制作可视化图看下
- The second game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
- Kotlin basic learning 14
- First acquaintance with string+ simple usage (II)
- 数据库文件逻辑结构形式指的是什么
- JS generate random numbers
- Influence of air resistance on the trajectory of table tennis
- 【DesignMode】建造者模式(Builder model)
猜你喜欢

一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起

【DesignMode】建造者模式(Builder model)

蓝桥杯单片机第六届温度记录器

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

蓝桥杯单片机省赛第十一届第一场

Unity脚本的基础语法(6)-特定文件夹

In wechat applet, the externally introduced JS is used in xwml for judgment and calculation

Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs

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

微信小程序中 在xwml 中使用外部引入的 js进行判断计算
随机推荐
Eight steps of agile development process
Oracle的md5
【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
[designmode] builder model
【小技巧】使用matlab GUI以对话框模式读取文件
树莓派GPIO引脚控制红绿灯与轰鸣器
Vite: configure IP access
High performance and low power cortex-a53 core board | i.mx8m Mini
【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
Basic syntax of unity script (6) - specific folder
FFMpeg AVFrame 的概念.
向数据库中存入数组数据,代码出错怎么解决
蓝桥杯单片机省赛第九届
蓝桥杯单片机省赛第十二届第二场
Oracle 常用SQL
Fingertips life Chapter 4 modules and packages
The 5th Blue Bridge Cup single chip microcomputer provincial competition
The 11th Blue Bridge Cup single chip microcomputer provincial competition
一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
Basic operations of MySQL database (based on tables)