Go Standards Recommendations
go get github.com/gookit/gsr
Std Logger
package main
import (
"github.com/gookit/gsr"
)
type MyApp struct {
logger gsr.StdLogger // std logger
}
func (ma *MyApp) SetLogger(logger gsr.StdLogger) {
ma.logger = logger
}
Full Logger
package main
import (
"github.com/gookit/gsr"
)
type MyApp struct {
logger gsr.Logger // full logger
}
func (ma *MyApp) SetLogger(logger gsr.Logger) {
ma.logger = logger
}
Simple Cache
package main
import (
"github.com/gookit/gsr"
)
type MyApp struct {
cacher gsr.SimpleCacher
}
func (ma *MyApp) SetCacher(cacher gsr.SimpleCacher) {
ma.cacher = cacher
}
// DataParser interface for Marshal/Unmarshal data
type DataParser interface {
Marshal(v any) ([]byte, error)
Unmarshal(data []byte, ptr any) error
}