mirror of
https://github.com/romdo/gomockctx.git
synced 2026-02-19 08:06:40 +00:00
docs(readme): add WithLabel and Any usage examples
This commit is contained in:
18
README.md
18
README.md
@@ -26,6 +26,8 @@ import "github.com/romdo/gomockctx"
|
||||
|
||||
## Usage
|
||||
|
||||
Match against a specific context or any of its child contexts:
|
||||
|
||||
```go
|
||||
// Create a context with a gomockctx ID value.
|
||||
ctx := gomockctx.New(context.Background())
|
||||
@@ -39,6 +41,22 @@ someMock.EXPECT().
|
||||
someMock.Get(ctx, "foo")
|
||||
```
|
||||
|
||||
Match against a context containing a specific value:
|
||||
|
||||
```go
|
||||
someMock.EXPECT().
|
||||
Get(gomockctx.WithValue(myCtxKey, "hello"), "foo").
|
||||
Return("bar", nil)
|
||||
```
|
||||
|
||||
Match against any context:
|
||||
|
||||
```go
|
||||
someMock.EXPECT().
|
||||
Get(gomockctx.Any(), "foo").
|
||||
Return("bar", nil)
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Please see the
|
||||
|
||||
Reference in New Issue
Block a user