Skip to content

Commit

Permalink
doc: add guide to use the wire:"-" tag (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
shantuo authored Jun 11, 2019
1 parent 000df02 commit 93b1ce7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ func injectFooBar() FooBar {

And similarly if the injector needed a `*FooBar`.

It is sometimes useful to prevent certain fields from being filled in by the
injector, especially when passing `*` to `wire.Struct`. You can tag a field with
`` `wire:"-"` `` to have Wire ignore such fields. For example:

```go
type Foo struct {
mu sync.Mutex `wire:"-"`
Bar Bar
}
```

When you provide the `Foo` type using `wire.Struct(new(Foo), "*")`, Wire will
automatically omit the `mu` field. Additionally, it is an error to explicitly
specify a prevented field as in `wire.Struct(new(Foo), "mu")`.

### Binding Values

Occasionally, it is useful to bind a basic value (usually `nil`) to a type.
Expand Down

0 comments on commit 93b1ce7

Please sign in to comment.