doc: add guide to use the wire:"-" tag (#195)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user