mirror of
https://github.com/tmrts/go-patterns.git
synced 2026-02-04 14:46:19 +00:00
idiom/functional-options: fix formatting and naming
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
# Functional Options
|
||||
|
||||
Functional options are a method of implementing clean/eloquent APIs in Go.
|
||||
Options implemented as a function set the state of that option.
|
||||
|
||||
## Implementation
|
||||
|
||||
### Options
|
||||
|
||||
```go
|
||||
package file
|
||||
|
||||
@@ -44,6 +46,7 @@ func Permissions(perms os.FileMode) Option {
|
||||
```
|
||||
|
||||
### Constructor
|
||||
|
||||
```go
|
||||
package file
|
||||
|
||||
@@ -77,6 +80,7 @@ func New(filepath string, setters ...Option) error {
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
emptyFile, err := file.New("/tmp/empty.txt")
|
||||
if err != nil {
|
||||
Reference in New Issue
Block a user