diff --git a/docs/guide.md b/docs/guide.md index a3157ee7..c1a15af8 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -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.