Created
October 15, 2017 00:51
-
-
Save lamarmarshall/ff5833591292a1c57acb46676a586162 to your computer and use it in GitHub Desktop.
golang loops, arrays and maps
This file contains 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() { | |
for i := 1; i <= 10; i++ { | |
fmt.Printf("%v -- %v \n", "super", "love") | |
} | |
x := []int{1, 2, 3, 4, 85, 6, 7} | |
for index, value := range x { | |
fmt.Printf("%d-%d,", index, value) | |
} | |
name := make(map[string]string) | |
name["lamar"] = "marshall" | |
name["mary"] = "carter" | |
name["china"] = "hill" | |
for first, last := range name { | |
fmt.Printf("%v %v\n", first, last) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment