go-kod / kod

A generics based dependency injection application framework for Go, support OpenTelemetry trace/metric/log natively 🚀🚀🚀
https://pkg.go.dev/github.com/go-kod/kod
Apache License 2.0
109 stars 3 forks source link

how to declare multi implements of one interface? #172

Closed leopku closed 3 weeks ago

leopku commented 4 weeks ago

https://github.com/leopku/kodtest/blob/master/cmd/demo3.go

type IStore interface {
    Get(string) any
    Set(string, any) error
}

type MemoryStore struct {
    kod.Implements[...]  <--
}

func (MemoryStore) Get(string) any {
    fmt.Println("dummy get called")
    return "dummy string"
}

func (MemoryStore) Set(string, any) error {
    fmt.Println("dummy set called")
    return nil
}

type DiskStore struct {
    kod.Implements[...]  <--
}

func (DiskStore) Get(string) any {
    fmt.Println("dummy get called")
    return "dummy string"
}

func (DiskStore) Set(string, any) error {
    fmt.Println("dummy set called")
    return nil
}
sysulq commented 4 weeks ago

It is not supported yet, which would make things complicated. But I'm open to this.

leopku commented 4 weeks ago

Thanks.

sysulq commented 3 weeks ago

Close this issue at this moment, feel free to reopen when someone want to contribute this feature.