Advertisement
cwchen

[Go] Map demo.

Sep 23rd, 2017
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.32 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5. )
  6.  
  7. func main() {
  8.     // Declare an empty map.
  9.     m := make(map[string]string)
  10.  
  11.     // Insert key/value pairs
  12.     m["Go"] = "Beego"
  13.     m["Python"] = "Django"
  14.     m["Ruby"] = "Rails"
  15.     m["PHP"] = "Laravel"
  16.  
  17.     // Call the value by the key.
  18.     if !(m["Go"] == "Beego") {
  19.         log.Fatal("Wrong value")
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement