gomonkey icon indicating copy to clipboard operation
gomonkey copied to clipboard

feature: replace the arguments of a function

Open eleztian opened this issue 2 years ago • 1 comments

Is there a more appropriate way to change the parameters of a function?

more complicated way....


var patchReadDir = gomonkey.NewPatches()
var readDir func(name string) ([]os.DirEntry, error)
readDir = func(name string) ([]os.DirEntry, error) {
        patchReadDir.Reset()
        defer patchReadDir.ApplyFunc(os.ReadDir, readDir)
        return os.ReadDir(filepath.Join(c.baseDir, name))
}
patchReadDir.ApplyFunc(os.ReadDir, readDir)
c.patches = append(c.patches, patchReadDir)

eleztian avatar Sep 24 '22 06:09 eleztian

I think it's related to https://github.com/agiledragon/gomonkey/issues/103

myzhan avatar Jun 29 '23 03:06 myzhan