Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var OptGeneric = optGeneric{}
View Source
var OptGlobal = optGlobal{}
Functions ¶
func PatchEmpty ¶
func PatchEmpty(target interface{})
PatchEmpty patches target with empty patch. Call the target will run the original func.
Types ¶
type PatchGuard ¶
type PatchGuard struct {
// contains filtered or unexported fields
}
func Patch ¶
func Patch(target, replacement interface{}, opts ...Option) *PatchGuard
Patch replaces a function with another for current goroutine only.
Usage examples:
Patch(math.Abs, func(n float64) { return 0 }) Patch((*net.Dialer).Dial, func(_ *net.Dialer, _, _ string) (net.Conn, error) {})
func PatchInstanceMethod ¶
func PatchInstanceMethod(target reflect.Type, methodName string, replacement interface{}) *PatchGuard
PatchInstanceMethod replaces an instance method methodName for the type target with replacement Replacement should expect the receiver (of type target) as the first argument
func (*PatchGuard) Restore ¶
func (g *PatchGuard) Restore()
func (*PatchGuard) Unpatch ¶
func (g *PatchGuard) Unpatch()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.