Skip to content

Instantly share code, notes, and snippets.

@xvbnm48
Created December 18, 2022 02:39
Show Gist options
  • Save xvbnm48/3ce67d5dcc98d24e677fb260a8f4bb5f to your computer and use it in GitHub Desktop.
Save xvbnm48/3ce67d5dcc98d24e677fb260a8f4bb5f to your computer and use it in GitHub Desktop.
map in golang
package main
import "fmt"
func main() {
// Membuat map dengan make
a := make(map[string]int)
a["apple"] = 10
a["banana"] = 5
fmt.Println(a) // Output: map[apple:10 banana:5]
// Membuat map dengan sintaks map[K]V
b := map[string]int{
"apple": 10,
"banana": 5,
}
fmt.Println(b) // Output: map[apple:10 banana:5]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment