The inner if else is not being reached although its correct. I don't know why its not matching the equality test for strings as a result of which the call to functions using interface variable is not working
fmt.Println("Enter a valid query:")
fmt.Printf(">")
reader:=bufio.NewReader(os.Stdin)
inp,_:=reader.ReadString('\n')
query:=strings.Split(inp," ")
fmt.Println("0 : ",query[0])
fmt.Println("1 : ",query[1])
st:=query[1]
if query[0]=="cow"{
fmt.Println("inside cow going to",st)
var a animal=cow{"Cow"}
if query[1]=="eat"{
a.eat()
} else if query[1]=="move"{
a.move()
} else if st=="speak"{
fmt.Println("inside cow speak")//Not reaching here even
a.speak()
}
}
Aucun commentaire:
Enregistrer un commentaire