learn go ifelse

简介: package main // 参考文档: // https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/05.
package main

// 参考文档:
//     https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/05.1.md

import "fmt"

func main() {
    var first int = 10
    var cond int

    if first <= 0 {
        fmt.Printf("first is less than or equal to 0\n")
    } else if first > 0 && first < 5 {
        fmt.Printf("first is between 0 and 5\n")
    } else {
        fmt.Printf("first is 5 or greater\n")
    }

    if cond = 5; cond > 10 {
        fmt.Printf("cond is greater than 10\n")
    } else {
        fmt.Printf("cond is not greater than 10\n")
    }
}

 

目录
相关文章
Go to Learn Go之命令行参数
Go to Learn Go之命令行参数
140 8
|
Serverless Go
Go to Learn Go之时间日期
Go to Learn Go之时间日期
167 8
Go to Learn Go之Gob
Go to Learn Go之Gob
77 8
Go to Learn Go之文件操作
Go to Learn Go之文件操作
83 8
Go to Learn Go之反射
Go to Learn Go之反射
122 8
|
存储 安全 Go
Go to Learn Go之并发
Go to Learn Go之并发
78 8
|
存储 Go
Go to Learn Go之类型转换
Go to Learn Go之类型转换
148 8
Go to Learn Go之错误处理
Go to Learn Go之错误处理
120 8
|
存储 Go
Go to Learn Go之接口
Go to Learn Go之接口
139 7
Go to Learn Go之作用域
Go to Learn Go之作用域
112 5

热门文章

最新文章