Go by Example - If/Else
Go by Example
Go is an open source programming language designed for building simple, fast, and reliable software.
Go by Example is a hands-on introduction to Go using annotated example programs. Check out the first example or browse the full list below.
Go by Example: If/Else
goalng中的if条件语句可以省略括号,但是大括号不能少。而且golang没有常用的三元运算符?:
, 所以必须用if来实现。
1 | package main |
1 | $ go run if-else.go |