Advertisement
cwchen

[Go] Passing boolean as error.

Oct 28th, 2017
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.25 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5. )
  6.  
  7. func main() {
  8.     m := map[int]string{
  9.         1: "one",
  10.         2: "two",
  11.         3: "three",
  12.     }
  13.  
  14.     v, ok := m[1]
  15.     if !ok {
  16.         log.Fatal("Unable to retrieve key/value pair")
  17.     }
  18.  
  19.     if !(v == "one") {
  20.         log.Fatal("Wrong value")
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement