learn go ifelse

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
")
    } else if first > 0 && first < 5 {
        fmt.Printf("first is between 0 and 5
")
    } else {
        fmt.Printf("first is 5 or greater
")
    }

    if cond = 5; cond > 10 {
        fmt.Printf("cond is greater than 10
")
    } else {
        fmt.Printf("cond is not greater than 10
")
    }
}
原文地址:https://www.cnblogs.com/zengjfgit/p/4985582.html