Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gookit/gsr
Go Standards Recommendations - common interfaces. e.g: cache, logger. Golang 一些通用的接口定义
https://github.com/gookit/gsr
go-cache go-logger golang golang-interface interface-design logger
Last synced: about 1 month ago
JSON representation
Go Standards Recommendations - common interfaces. e.g: cache, logger. Golang 一些通用的接口定义
- Host: GitHub
- URL: https://github.com/gookit/gsr
- Owner: gookit
- License: mit
- Created: 2021-05-26T02:07:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T15:49:22.000Z (10 months ago)
- Last Synced: 2024-06-19T19:42:48.338Z (6 months ago)
- Topics: go-cache, go-logger, golang, golang-interface, interface-design, logger
- Language: Go
- Homepage: https://pkg.go.dev/github.com/gookit/gsr
- Size: 25.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GSR
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/gsr?style=flat-square)
[![GoDoc](https://godoc.org/github.com/gookit/gsr?status.svg)](https://pkg.go.dev/github.com/gookit/gsr)
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/gsr)](https://goreportcard.com/report/github.com/gookit/gsr)Go Standards Recommendations
## Install
```bash
go get github.com/gookit/gsr
```## Interfaces
- [logger](logger.go)
- [cacher](cacher.go)
- [parser](parser.go)## Usage
### Logger Interface
**Std Logger**
```go
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**
```go
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**
```go
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
```go
// DataParser interface for Marshal/Unmarshal data
type DataParser interface {
Marshal(v any) ([]byte, error)
Unmarshal(data []byte, ptr any) error
}
```## LICENSE
[MIT](LICENSE)