First code: http://play.golang.org/p/OEDetydMbW
Second code: http://play.golang.org/p/QZIrWALAm_
Can somebody explain me why I am not getting error on First code, I was expecting to error out stating missing CreateTable method
.
First code: http://play.golang.org/p/OEDetydMbW
Second code: http://play.golang.org/p/QZIrWALAm_
Can somebody explain me why I am not getting error on First code, I was expecting to error out stating missing CreateTable method
.
You specify an interface Abc
with the method CreateTable
but none of your variable are actually of type interface Abc
This slightly modified version will bring the error you seek:
http://play.golang.org/p/ETdexzPYaM
package main
import "log"
// Abc asdlkfjaslf as
type Abc interface {
CreateTable(a, b)
}
type a int
type b int
// Def klajsdlfkjaslfd
type Def int
// // CreateTable laksjdfljasfdl
// func (d *Def) CreateTable() {
// log.Println("inside Def CreateTable....")
// }
func main() {
var m1 Abc = Def(5)
log.Println("inside main %d", m1)
}