当前位置:网站首页>Go语言自学系列 | golang中的if else语句
Go语言自学系列 | golang中的if else语句
2022-07-03 15:34:00 【51CTO】
视频来源:B站《golang入门到项目实战 [2021最新Go语言教程,没有废话,纯干货!持续更新中...]》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴: Go语言自学系列 | 汇总_COCOgsta的博客-CSDN博客
go语言中的if else语句可以根据给定条件二选一。
go语言的if else语句语法
go语言if else语句实例
比较两个数的大小
运行结果
判断一个数是奇数还是偶数
运行结果
判断一个人是否成年
运行结果
特殊写法,在if前面添加执行语句
运行结果
go语言if语句使用提示:
- 不需使用括号将条件包含起来
- 大括号{}必须存在,即使只有一行语句
- 左括号必须在if或else的同一行
- 在if之后,条件语句之前,可以添加变量初始化语句,使用;进行分隔
边栏推荐
- Get the executable path through the process PID (queryfullprocessimagename)
- Automatic generation of client code from flask server code -- Introduction to flask native stubs Library
- Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
- Digital image processing -- popular Canny edge detection
- Kubernetes 进阶训练营 Pod基础
- 大csv拆分和合并
- 【日常训练】395. 至少有 K 个重复字符的最长子串
- Analysis of development mode process based on SVN branch
- 【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
- Srs4.0+obs studio+vlc3 (environment construction and basic use demonstration)
猜你喜欢

Concurrency-01-create thread, sleep, yield, wait, join, interrupt, thread state, synchronized, park, reentrantlock

Find mapping relationship

Kubernetes advanced training camp pod Foundation

秒殺系統3-商品列錶和商品詳情

Seckill system 3- product list and product details

秒杀系统2-Redis解决分布式Session问题
![MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)

Idea does not specify an output path for the module

Popular understanding of random forest

WinDbg analysis dump file
随机推荐
Vs2017 is driven by IP debugging (dual machine debugging)
CString在多线程中的问题
Enable multi-threaded download of chrome and edge browsers
VC下Unicode和ANSI互转,CStringW和std::string互转
WinDbg分析dump文件
Location of software installation information and system services in the registry
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
详解指针进阶2
Construction of operation and maintenance system
Jvm-06-execution engine
Jvm-04-runtime data area heap, method area
do{}while()的妙用
Idea does not specify an output path for the module
VS2017通过IP调试驱动(双机调试)
Introduction, use and principle of synchronized
Find mapping relationship
Redis在Windows以及Linux系统下的安装
秒杀系统2-Redis解决分布式Session问题
Popular understanding of decision tree ID3
Tensorflow realizes verification code recognition (II)