Skip to content

Commit

Permalink
Fix go-functional-options
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-Leo committed Nov 20, 2023
1 parent d247e86 commit e93b951
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions content/posts/go-functional-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ func WithConvertible(convertible string) CarOption {
}
}

func WithEngineСapacity(engineСapacity float64) CarOption {
func WithEngineCapacity(engineСapacity float64) CarOption {
return func(c *Car) {
c.engineСapacity = engineСapacity
}
}

func WithFuelСonsumption(fuelСonsumption float64) CarOption {
func WithFuelConsumption(fuelСonsumption float64) CarOption {
return func(c *Car) {
c.fuelСonsumption = fuelСonsumption
}
Expand All @@ -148,8 +148,8 @@ func WithOwners(owners []string) CarOption {
```go
car := NewCar(WithBrand("Lada"),
WithConvertible(true),
WithEngineСapacity(1.4),
WithFuelСonsumption(7.4),
WithEngineCapacity(1.4),
WithFuelConsumption(7.4),
WithOwners([]string{"Василий", "Пётр"}))
```
Помимо этого можно написать функции, задающие полям структуры какие-либо часто используемые, но отличные от дефолтных значения.
Expand All @@ -166,8 +166,8 @@ func Convertible() CarOption {
```go
car := NewCar(WithBrand("Lada"),
Convertible(),
WithEngineСapacity(1.4),
WithFuelСonsumption(7.4),
WithEngineCapacity(1.4),
WithFuelConsumption(7.4),
WithOwners([]string{"Василий", "Пётр"}))
```
#### Объяснение
Expand Down

0 comments on commit e93b951

Please sign in to comment.