how to if-else in golang

if
if condition {
    //do something
}
if-else
if condition {
    //do something
} else {
    //do something
}

if-elseif-else
if condition {
    //do something
} else if condition2 {
    //do something
} else {
    //do something
}

check a string is empty
if str == "" { ... }
if len(str) == 0 {...}
check system
if runtime.GOOS == "windows" {
    // do something
} else {  //unix-like
    // do something
}

這個網誌中的熱門文章

原版周公解夢