Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Record and replay your HTTP interactions for fast, deterministic and accurate tests
| Date | Stars |
|---|---|
| 2026-07-24 | 1394 |
| 2026-07-25 | 1394 |
| 2026-07-28 | 1394 |
| 2026-07-30 | 1394 |
| 2026-08-06 | 1394 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
15.0
growth rate 0.00%/day
## go-vcr
[](https://github.com/dnaeon/go-vcr/actions/workflows/test.yaml/badge.svg)
[](https://pkg.go.dev/gopkg.in/dnaeon/go-vcr.v4)
[](https://goreportcard.com/report/gopkg.in/dnaeon/go-vcr.v4)
[](https://codecov.io/gh/dnaeon/go-vcr)
`go-vcr` simplifies testing by recording your HTTP interactions and replaying
them in future runs in order to provide fast, deterministic and accurate testing
of your code.
`go-vcr` was inspired by the [VCR library for Ruby](https://github.com/vcr/vcr).
## Installation
Install `go-vcr` by executing the command below:
```bash
$ go get -v gopkg.in/dnaeon/go-vcr.v4
```
Note, that if you are migrating from a previous version of `go-vcr`, you may
need to re-create your tests cassettes.
## Usage
A quick example of using `go-vcr`.
``` go
package helloworld_test
import (
"path/filepath"
"strings"
"testing"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)
func TestHelloWorld(t *testing.T) {
// Create our recorder
r, err := recorder.New(filepath.Join("testdata", strings.ReplaceAll(t.Name(), "/", "_")))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
// Make sure recorder is stopped once done with it.
if err := r.Stop(); err != nil {
t.Error(err)
}
})
client := r.GetDefaultClient()
url := "https://go.dev/VERSION?m=text"
resp, err := client.Get(url)
if err != nil {
t.Fatalf("Failed to get url %s: %s", url, err)
}
t.Logf("GET %s: %d\n", url, resp.StatusCode)
}
```
Running this test code for the first time will result in creating the
`testdata/TestHelloWorld.yaml` cassette, which will contain the recorded HTTP
interaction between our HTTP client and the remote server.
When we execute this test next time, what would happen is that `go-vcr` will
replay the already recorded HTTP interactions from the cassette, instead of
making actual external calls.
Please also check the [examples](./examples) directory from this repo for
complete and ready to run examples.
You can also refer to the [test cases](./pkg/recorder/recorder_test.go) for
additional examples.
## Custom YAML Marshaling Function
If you need control how YAML is encoded, set `WithMarshalFunc` with a custom
func. This defaults to `yaml.Marshal`.
```go
package marshalfunc_test
import (
"bytes"
"path/filepath"
"strings"
"testing"
"go.yaml.in/yaml/v4"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)
func TestCustomMarshalFunc(t *testing.T) {
marshalFunc := func(in any) ([]byte, error) {
var buf bytes.Buffer
enc := yaml.NewEncoder(&buf)
// Example of custom options from
// https://pkg.go.dev/go.yaml.in/yaml/v4
enc.CompactSeqIndent()
enc.SetIndent(4)
if err := enc.Encode(in); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
r, err := recorder.New(
filepath.Join("testdata", strings.ReplaceAll(t.Name(), "/", "_")),
recorder.WithMarshalFunc(marshalFunc),
)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
if err := r.Stop(); err != nil {
t.Error(err)
}
})
client := r.GetDefaultClient()
resp, err := client.Get("https://go.dev/VERSION?m=text")
if err != nil {
t.Fatal(err)
}
resp.Body.Close()
}
```
## Custom Request Matching
During replay mode, you can customize the way incoming requests are matched
against the recorded request/response pairs by defining a `recorder.MatcherFunc`
function.
For example, the following matcher will match on method, URL and body:
``` go
package matcher_test
import (
"bytes"
"io"
"net/http"
"path/filepath"
"strings"
"testing"
"gopkg.in/dnaeon/go-vcr.v4/pkg/cassette"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
)
func customMatcher(r *http.Request, i cassette.Request) bool {
if r.Body == nil || r.Body == http.NoBody {
Excerpt of 11,036 characters
Read on GitHub256
12
8
7
6
5
4
4
Andrey Nering · @charmbracelet · Brazil
3
Jean Mertz · Ethical Engineering · Netherlands
2
2
2
2
2
2
Gareth Jones · @ackama · New Zealand
2
2
1
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:75c8eb1e9e32a6a0, topic:testing