Hello

may be it is a trivial question but I could not find any usable answer to 
the following requirement therefore I thought that
surely some of you have the answer

Let's assume I have some code like follows:

func (obj *myObjStruct) MyFn(fsPath string) (myRetType, error) {
    cpath := path.Join(fsPath, "subdir", "input.txt")
    fh, err := os.Open(cpath)
    if err != nil {
        log.Error(fmt.Sprintf("Got error %#v", err))
        return nil, err
    }
    defer fh.Close()
    scanner := bufio.NewScanner(fh)
    for scanner.Scan() {
        inLine := scanner.Text()
        ...
 

How should I proceed to mock the os.Open and scanner.xxx calls so that I 
can exercise the remaining parts of the code (... above)

May be I need to rewrite this function a little bit before being able to do 
so but I obviously would not agree to lose the benefits of defering
fh.Close() call

Thanks for any advice/pointer/...

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to