# h2non/gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

Repository: https://github.com/h2non/gock
Canonical: https://ross.abutalabs.com/products/gock
Homepage: https://pkg.go.dev/github.com/h2non/gock
Language: Go
License: MIT
License Family: permissive
Topics: http, mocking, interception, expectations, assertions, http-transactions, mock, stubs, testing, api, http-server, http-api, go, https
Last push: 2024-09-24T10:01:06+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 3836, "days_push": 708, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2218, forks 112 (observed 2026-08-28T04:06:27.345453+00:00)

## What it is
gock is a Go library for declarative HTTP traffic mocking that intercepts outgoing requests via http.RoundTripper and matches them against defined expectations. It offers a fluent DSL for stubbing responses with matching by method, URL, headers, and body, inspired by JavaScript's nock.

## Use cases
- mock http responses in go tests
- stub external api calls in unit tests
- intercept net/http requests during testing
- simulate network timeouts and delays in go
- test http clients without hitting real servers
- mock  api responses in go

## When to choose
- you write Go tests that make outbound HTTP calls via net/http
- you want a nock-style fluent DSL for declaring HTTP expectations
- you need regex-based request matching or TTL-limited mocks

## When to avoid
- you need to mock gRPC or non-HTTP protocols
- you prefer running a real mock server over in-process interception
- your project is not written in Go

## Facets
- artifact type: library
- maturity: stable
- function: mocking, testing, http-client
- domain: testing, developer-tools, apis, web-development
- platform: go, cross-platform
- tags: http-mocking, http-interceptor, nock-inspired, stubbing, net-http, roundtripper, api-testing

## Member repositories
- h2non/gock (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:27.345453+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-30T02:45:54.193592+00:00, confidence not recorded.
  - readme: https://github.com/h2non/gock (fetched 2026-08-28T04:06:27.345453+00:00, sha 24a4bfae4c1c)
  - homepage: https://pkg.go.dev/github.com/h2non/gock (fetched 2026-08-29T10:26:03.266637+00:00, sha c57f404f6ee6)
  - site_page: https://pkg.go.dev/about (fetched 2026-08-29T10:26:03.656693+00:00, sha 757852027879)
  - site_page: https://go.dev/project (fetched 2026-08-29T10:26:03.671738+00:00, sha d5ca00bb378b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
