daily pastebin goal
11%
SHARE
TWEET

[Go] Passing boolean as error.

cwchen Oct 28th, 2017 274 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top