gsr

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 2 Imported by: 6

README

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
}
Marshaler interface
// Marshaler interface for Marshal/Unmarshal data
type Marshaler interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, ptr interface{}) error
}

LICENSE

MIT

Documentation

Overview

Package gsr is the Go standards recommendations interface definitions.

Source code and other details for the project are available at GitHub:

https://github.com/gookit/gsr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodedCacher added in v0.0.4

type CodedCacher interface {
	SimpleCacher

	// GetAs get and decode cache value to object ptr
	GetAs(key string, ptr interface{}) error
}

CodedCacher interface.

type Logger

type Logger interface {
	StdLogger
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
}

Logger interface definition

type Marshaler added in v0.0.3

type Marshaler interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, ptr interface{}) error
}

Marshaler interface for Marshal/Unmarshal data

type Printer

type Printer interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Printer interface definition

type SimpleCacher added in v0.0.2

type SimpleCacher interface {
	// Closer close cache handle
	io.Closer
	// Clear clear all caches
	Clear() error

	// Has basic operation
	Has(key string) bool
	Del(key string) error
	Get(key string) interface{}
	Set(key string, val interface{}, ttl time.Duration) error

	// GetMulti multi operation
	GetMulti(keys []string) map[string]interface{}
	SetMulti(values map[string]interface{}, ttl time.Duration) error
	DelMulti(keys []string) error
}

SimpleCacher interface definition

type StdLogger

type StdLogger interface {
	Printer
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
}

StdLogger interface definition. refer the go "log" package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL