Hi team,

I'm trying to write some mock class for unit test. And in the mock class, 
only part of function are changed. Is there any way to do so? For example, 
in the follow 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\n", mc.Object())
}

type FakeMyClass struct {
    MyClass
}

func (*FakeMyClass) Object() (int) {
    return 1
}

func main() {
    mc := &FakeMyClass{}
    mc.PrintInfo()
}



Thanks
Klaus

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to