Created
April 5, 2018 12:49
-
-
Save afreeland/cb6601fce67865e47500003ee782b1bc to your computer and use it in GitHub Desktop.
Go: basic branching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println("Hello, playground") | |
//foo := 1 | |
if foo := 2; foo == 1 { | |
fmt.Println("bar") | |
} else { | |
fmt.Println("buz") | |
} | |
// Initialize bar, and then check cases | |
switch bar := 1; bar { | |
case 1: | |
fmt.Println("bar is 1") | |
case 2: | |
fmt.Println("bar is 2") | |
} | |
// Advanced Case | |
test := 1 | |
switch { | |
case test == 1: | |
fmt.Println("test is equal to 1") | |
case test > 2: | |
fmt.Println("test is greater than") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment