# bouk/monkey

Monkey patching in Go

Repository: https://github.com/bouk/monkey
Canonical: https://ross.abutalabs.com/products/bouk-monkey
Homepage: https://bou.ke
Language: Go
License: NOASSERTION
License Family: other
Archived: true
Last push: 2020-06-17T09:49:36+00:00

## Health v2 (maintenance only)
Score: 10/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 4176, "days_push": 2268, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, archived, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3424, forks 363 (observed 2026-08-28T04:08:03.898687+00:00)

## What it is
A Go library that enables monkey patching of functions and instance methods at runtime by rewriting the running executable to insert jumps to replacement functions. It is explicitly intended for use in testing environments only, as the technique is inherently unsafe.

## Use cases
- monkey patch functions in Go tests
- mock net.Dial to disable network access in tests
- replace fmt.Println with a stub during testing
- patch instance methods for all instances of a type
- call the original function from within a replacement using PatchGuard
- unpatch all replacements in test teardown

## When to choose
- you need to stub out functions or methods in Go tests that cannot be injected via interfaces
- you want to disable network or side effects in integration tests
- you need to intercept calls to third-party functions you cannot modify

## When to avoid
- in production code, since runtime executable rewriting is unsafe
- on platforms where the binary rewriting technique is unsupported
- you need to patch a method for only a single instance
- your project requires a permissive or standard license (license is non-standard)

## Facets
- artifact type: library
- maturity: maintenance
- function: testing, mocking, developer-tools
- domain: developer-tools, testing
- platform: go
- tags: monkey-patching, runtime-patching, test-doubles, unsafe, linux, macos

## Member repositories
- bouk/monkey (main) score 10

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:03.898687+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:38:05.143814+00:00, confidence not recorded.
  - readme: https://github.com/bouk/monkey (fetched 2026-08-28T04:08:03.898687+00:00, sha 78c10eaa6c09)
  - homepage: https://bou.ke (fetched 2026-08-29T09:32:07.792371+00:00, sha b2422ce3be5b)
  - site_page: https://bou.ke/about (fetched 2026-08-29T09:32:07.801253+00:00, sha 0db175128aa0)
- Data as of 2026-08-30T08:39:29.467469+00:00.
