Skip to content

Instantly share code, notes, and snippets.

@dallarosa
Created July 5, 2013 06:25
Show Gist options
  • Save dallarosa/5932372 to your computer and use it in GitHub Desktop.
Save dallarosa/5932372 to your computer and use it in GitHub Desktop.
Example of use of empty interface
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