Skip to content

feature: replace the arguments of a function #111

Open
@eleztian

Description

@eleztian

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions