Tag interfaces

Golang Tips & Tricks #2 - interfaces

When it comes to interfaces, a good practice is to create an interface where you’ll use it. Creating interfaces in advanced is not recommended in Go. There are two exceptions: you’re creating a library which will be used in different projects you’ll have more than 1 implementation In the example below, we have a storage implementation. type inMemoryStorage struct { mutex *sync.Mutex storage map[string]*Value } func NewStorage() *inMemoryStorage { return &inMemoryStorage{ storage: map[string]*Value{}, mutex: &sync.