Open eleztian opened 1 year ago
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)
I think it's related to https://github.com/agiledragon/gomonkey/issues/103
Is there a more appropriate way to change the parameters of a function?
more complicated way....