73 lines
951 B
Go
73 lines
951 B
Go
package main
|
|
|
|
BAD
|
|
// Producer
|
|
|
|
type CustomerStorage interface {
|
|
StoreCustomer(customer string) error
|
|
GetCustomer(is string) error
|
|
UpdateCustomer(customer string) error
|
|
GetAllCustomers() ([]string,error)
|
|
GetCustomerWithoutContract() ([]string,error)
|
|
}
|
|
|
|
//======================================
|
|
|
|
|
|
// Consumer
|
|
|
|
type customerGetter interface {
|
|
GetAllCustomers() ([]string,error)
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
type IntConfig struct {
|
|
// ...
|
|
}
|
|
|
|
func (c IntConfig) Get() int { <======== PRODUCER
|
|
return 0
|
|
}
|
|
|
|
func (c IntConfig) Set(value int) {
|
|
//...
|
|
}
|
|
|
|
|
|
|
|
Consumer
|
|
|
|
type confifSetter interface{
|
|
Set()
|
|
}
|
|
|
|
type configGetter interface {
|
|
Get() int
|
|
}
|
|
|
|
type Mixed interface {
|
|
confifSetter
|
|
configGetter
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Foo struct {
|
|
threshold configGetter
|
|
}
|
|
|
|
func NewFoo(new_threshold configGetter) Foo {
|
|
return Foo{threshold: new_threshold}
|
|
}
|
|
|
|
func (f Foo) Bar() {
|
|
threshold := f.threshold.Get()
|
|
}
|