Registry / testing / monkey

monkey

JSON →
library1.0.2gogounverified

A Go library for monkey patching functions and methods at runtime.

go get bou.ke/monkey
INSTALL
IMPORT
SIG · MONKEY
M
monkey
testinggov1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

monkey
bou.ke/monkey

Patch fmt.Println to always print 'patched'

package main import ( "fmt" "bou.ke/monkey" ) func main() { monkey.Patch(fmt.Println, func(a ...interface{}) (n int, err error) { return fmt.Println("patched") }) fmt.Println("test") }
Debug
Known issues
gotchaMonkey patching is unsafe and may cause crashes on certain architectures or Go versions.
fix
Use interfaces or dependency injection instead of monkey patching.
affects: >=1.0.0
Upgrade
Version history
1.0.2latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
monkey — go get monkey · libregistry