1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-10 09:50:58 +02:00

Document functional options (#1899)

* Document functional options

* Update CONTRIBUTING.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
Robert Pająk 2021-05-12 03:28:46 +02:00 committed by GitHub
parent cabf0c0782
commit ae85fab3c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -294,6 +294,23 @@ func WithMyType(t MyType) Option {
}
```
##### Functional Options
```go
type optionFunc func(*config)
func (fn optionFunc) apply(c *config) {
fn(c)
}
// WithMyType sets t as MyType.
func WithMyType(t MyType) Option {
return optionFunc(func(c *config) {
c.MyType = t
})
}
```
#### Instantiation
Using this configuration pattern to configure instantiation with a `NewT`