Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 403 Bytes

File metadata and controls

29 lines (23 loc) · 403 Bytes
type IntConfig struct {
	v int
}

func (c *IntConfig) Get() int {
	return c.v
}

func (c *IntConfig) Set(v int) {
	c.v = v
}

type IntConfigGetter interface {
	Get() int
}

type Foo struct {
	config IntConfigGetter
}

func (f Foo) Bar() {
	println(f.config.Get()) // у config есть только .Get(), но не .Set()
}

func NewFoo(config IntConfigGetter) *Foo {
	return &Foo{config}
}