[go: up one dir, main page]

Skip to content
/ gsr Public

Go Standards Recommendations - common interfaces. e.g: cache, logger. Golang 一些通用的接口定义

License

Notifications You must be signed in to change notification settings

gookit/gsr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GSR

GitHub go.mod Go version GoDoc Go Report Card

Go Standards Recommendations

Install

go get github.com/gookit/gsr

Interfaces

Usage

Logger Interface

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
}

Cache Interface

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

// DataParser interface for Marshal/Unmarshal data
type DataParser interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, ptr any) error
}

LICENSE

MIT