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 ( | |
| "time" | |
| "github.com/foo/greeter" | |
| weather "github.com/bar/climate" | |
| ) | |
| func main() { |
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() { | |
| slicedArray1 := make([]string, 4) | |
| var slicedArray2 []string | |
| slicedArray3 := []string{} | |
| slicedArray4 := []string{"foo", "bar"} |
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
| slicedArray1 := make([]string, 2) | |
| var slicedArray2 []string | |
| slicedArray3 := []string{} | |
| slicedArray4 := []string{"foo", "bar"} |
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() { | |
| var oldArray [2]string | |
| var newArray [2]string | |
| oldArray[0] = "foo" |
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 ( | |
| "github.com/google/uuid" | |
| "fmt" | |
| ) | |
| func main() { | |
| var array []interface{} | |
| array = []interface{}{"apple", 1, uuid.New()} |
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
| var array [3]string | |
| array = [3]string{"string", 1, uuid.New()} | |
| // Error | |
| println(array) |
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() { | |
| produce := []interface{}{ | |
| map[string]string{ | |
| "name": "apple", | |
| "flavour": "It's a little sour and bitter, but mostly sweet, not at all salty, very juicy in general.", | |
| "kind": "fruit", |
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
| var variable = map[keyType]valueType{} | |
| variable[keyName] = Value | |
| println(variable[keyName]) // Value |
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" | |
| "github.com/google/uuid" | |
| ) | |
| func main() { | |
| variable := map[interface{}]string{} | |
| variable[1] = "from an integer key" |
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
| variable := map[keyType]valueType{} | |
| variable[keyName] = Value | |
| println(variable[keyName]) // Value |