Skip to content

Instantly share code, notes, and snippets.

@arunshaji95
Created February 13, 2019 09:11
Show Gist options
  • Save arunshaji95/140b5c65d452085f5fc74e4d84a3eb2b to your computer and use it in GitHub Desktop.
Save arunshaji95/140b5c65d452085f5fc74e4d84a3eb2b to your computer and use it in GitHub Desktop.
Dynamic typing in Golang
package main
import (
"fmt"
)
type I interface {
Test()
}
type A struct{}
func (A) Test() {}
type B struct{}
func (B) Test() {}
func main() {
var i I
i = A{}
fmt.Println("Type: %T\n", i)
i = B{}
fmt.Println("Type : %T\n", i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment