daily pastebin goal
36%
SHARE
TWEET

[Go] Void interface demo.

cwchen Oct 7th, 2017 319 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     var v interface{}
  9.  
  10.     // v is an integer.
  11.     v = 1
  12.     fmt.Println(v)
  13.  
  14.     // v becomes a string now.
  15.     v = "Hello"
  16.     fmt.Println(v)
  17.  
  18.     // v becomes a boolean value now.
  19.     v = true
  20.     fmt.Println(v)
  21. }
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