go-tour/empty-interface.go

19 lines
212 B
Go
Raw Normal View History

2020-02-08 22:39:18 +00:00
package main
import "fmt"
func main() {
var i interface{}
describe(i)
i = 42
describe(i)
i = "hello"
describe(i)
}
func describe(i interface{}) {
fmt.Printf("(%v, %T)\n", i, i)
}