Created
July 5, 2013 06:25
-
-
Save dallarosa/5932372 to your computer and use it in GitHub Desktop.
Example of use of empty interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type myStruct struct { | |
RandomString string | |
RandomNumber int | |
} | |
func iPrintAnything(a interface{}) { | |
fmt.Println(a) | |
} | |
func main() { | |
iPrintAnything(1) | |
iPrintAnything("aaa") | |
iPrintAnything(myStruct{RandomString:"kkk", RandomNumber:111}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment