I'm trying to build mock class for unit test in golang; does anyone know how to do that? For example, in the following code slice, I'd like to print FakeMyClass.Object's return value.
package main
import (
"fmt"
)
type MyClass struct {
}
func (*MyClass) Object() (int) {
return 0
}
func (mc *MyClass) PrintInfo() {
fmt.Printf("%v
", mc.Object())
}
type FakeMyClass struct {
MyClass
}
func (*FakeMyClass) Object() (int) {
return 1
}
func main() {
mc := &FakeMyClass{}
mc.PrintInfo()
}