kitgo

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 87 Imported by: 0

README

kitgo

reference go report release test

Overview

Package kitgo is the Go wrapper library used in hokonco go application

Documentation

Overview

Package kitgo is a set of curated golang helpers intended to ease development process, created by wrapping commonly used package and modules

Package kitgo is a generated GoMock package.

Index

Constants

View Source
const (
	AcceptEncoding      = "Accept-Encoding"
	ContentType         = "Content-Type"
	ContentEncoding     = "Content-Encoding"
	XContentTypeOptions = "X-Content-Type-Options"
)

Variables

View Source
var Base64 = base64_{}
View Source
var Compress compress_
View Source
var Crypto crypto_
View Source
var Dir dir_
View Source
var Graphics graphics_
View Source
var HTTP http_

JSON is a jsoniter.API with ConfigFastest, satisfied encoding/json package

View Source
var Log log_
View Source
var Prometheus prometheus_
View Source
var Redis redis_

Redis implement a wrapper around "go-redis/redis"

View Source
var Ristretto ristretto_
View Source
var SMTP smtp_

SMTP implement a wrapper around standard "html/template" so that the SMTP is limited to Parse & Execute

View Source
var SQL sql_

SQL implement a wrapper around standard "database/sql" and extend it to be able to support Statement and Done

View Source
var Template template

Functions

func ListenToSignal

func ListenToSignal(sigs ...os.Signal) os.Signal

ListenToSignal will block until receiving signal from input

func NewErrors added in v0.0.2

func NewErrors(errs ...error) errorList

func PanicWhen

func PanicWhen(condition bool, v interface{})

PanicWhen execute a panic when condition is met and v is not nil

func Parallel

func Parallel(ctx context.Context, onError func(int, error), tasks ...func() error)

Parallel receive cancelable context and receiving error channel along with list of tasks, a func() error that will execute in asynchronous manners

if receiving error channel is unbuffered, it will block the current execution process, would be better if receiving error channel is buffered with len(tasks)

context is also cancelable and this is to run in go routine

func RecoverWith

func RecoverWith(catch func(recv interface{}))

RecoverWith will catch error value passed when panic

func ShouldCover

func ShouldCover(code int, required float64) int

ShouldCover

Types

type AESGCM added in v0.0.2

type AESGCM struct{ cipher.AEAD }

func (*AESGCM) Open added in v0.0.2

func (x *AESGCM) Open(ciphertext []byte) (plaintext []byte, err error)

func (*AESGCM) Seal added in v0.0.2

func (x *AESGCM) Seal(plaintext []byte) (ciphertext []byte)

type Base64Wrapper added in v0.0.2

type Base64Wrapper struct {
	// contains filtered or unexported fields
}

func (Base64Wrapper) AtoB added in v0.0.2

func (x Base64Wrapper) AtoB(b []byte) []byte

func (Base64Wrapper) BtoA added in v0.0.2

func (x Base64Wrapper) BtoA(b []byte) []byte

type Brotli added in v0.0.2

type Brotli struct {
	// contains filtered or unexported fields
}

func (*Brotli) Read added in v0.0.2

func (x *Brotli) Read(dst io.Writer, src io.Reader) (err error)

func (*Brotli) Write added in v0.0.2

func (x *Brotli) Write(dst io.Writer, src io.Reader) (err error)

type Client added in v0.0.2

type Client struct {
	*Brotli
	*Flate
	*Gzip
	*Minify
}

type ConsoleWriter added in v0.0.2

type ConsoleWriter = zerolog.ConsoleWriter

type CryptoWrapper added in v0.0.2

type CryptoWrapper struct{}

func (*CryptoWrapper) Argon2I added in v0.0.2

func (*CryptoWrapper) Argon2I(password []byte) []byte

func (*CryptoWrapper) Argon2ICompareHashAndPassword added in v0.0.2

func (*CryptoWrapper) Argon2ICompareHashAndPassword(hashed, password []byte) bool

func (*CryptoWrapper) Argon2ID added in v0.0.2

func (*CryptoWrapper) Argon2ID(password []byte) []byte

func (*CryptoWrapper) Argon2IDCompareHashAndPassword added in v0.0.2

func (*CryptoWrapper) Argon2IDCompareHashAndPassword(hashed, password []byte) bool

func (*CryptoWrapper) BCrypt added in v0.0.2

func (*CryptoWrapper) BCrypt(password []byte) []byte

func (*CryptoWrapper) BCryptCompareHashAndPassword added in v0.0.2

func (*CryptoWrapper) BCryptCompareHashAndPassword(hashed, password []byte) bool

func (*CryptoWrapper) NewAESGCM added in v0.0.2

func (*CryptoWrapper) NewAESGCM(password []byte) *AESGCM

func (*CryptoWrapper) NewECDSA added in v0.0.2

func (*CryptoWrapper) NewECDSA(curv elliptic.Curve) (*ECDSA, error)

func (*CryptoWrapper) NewNaCl added in v0.0.2

func (*CryptoWrapper) NewNaCl() *NaCl

func (*CryptoWrapper) NewRSA added in v0.0.2

func (*CryptoWrapper) NewRSA(bits int) (*RSA, error)

func (*CryptoWrapper) NewTLSConfig added in v0.0.2

func (*CryptoWrapper) NewTLSConfig(certFile, keyFile, dirCache string, hostWhitelist ...string) *tls.Config

func (*CryptoWrapper) Nonce added in v0.0.2

func (*CryptoWrapper) Nonce(length int) []byte

func (*CryptoWrapper) ReadECDSA added in v0.0.2

func (*CryptoWrapper) ReadECDSA(key, pub io.Reader) (*ECDSA, error)

func (*CryptoWrapper) ReadRSA added in v0.0.2

func (*CryptoWrapper) ReadRSA(key, pub io.Reader) (*RSA, error)

func (*CryptoWrapper) SCrypt added in v0.0.2

func (*CryptoWrapper) SCrypt(password []byte) []byte

func (*CryptoWrapper) SCryptCompareHashAndPassword added in v0.0.2

func (*CryptoWrapper) SCryptCompareHashAndPassword(hashed, password []byte) bool

func (*CryptoWrapper) SHA256 added in v0.0.2

func (*CryptoWrapper) SHA256(b []byte) []byte

func (*CryptoWrapper) SHA512 added in v0.0.2

func (*CryptoWrapper) SHA512(b []byte) []byte

type Currency

type Currency struct {
	// Tag parse according to BCP47 string
	Tag string

	// Value contains the value of currency
	Value float64

	// Format default to "%[1]s %[2]s" means currency sign, followed by value
	// %[1]s is a currency sign by language
	// %[2]s is a parsed Value
	//
	// According to each format, e.g.
	Format string
}

Currency immutable struct contains price & its format

func (Currency) MarshalJSON

func (c Currency) MarshalJSON() ([]byte, error)

MarshalJSON implement json marshaler

func (Currency) String

func (c Currency) String() string

String implement a stringer interface

type Dict

type Dict map[string]interface{}

Dict extends `map[string]interface{}`, and it should be used to represent json-like data

func (*Dict) Delete

func (d *Dict) Delete(k string)

func (*Dict) Map

func (d *Dict) Map(fn func(k string, v interface{}))

func (*Dict) Set

func (d *Dict) Set(k string, v interface{})

type DirConfig added in v0.0.2

type DirConfig struct{ Path string }

type DirWrapper added in v0.0.2

type DirWrapper struct {
	// contains filtered or unexported fields
}

func (*DirWrapper) Dirs added in v0.0.2

func (x *DirWrapper) Dirs() []*DirWrapper

func (*DirWrapper) Files added in v0.0.2

func (x *DirWrapper) Files() []*os.File

func (*DirWrapper) FilesInfo added in v0.0.2

func (x *DirWrapper) FilesInfo() []os.FileInfo

func (*DirWrapper) Filter added in v0.0.2

func (x *DirWrapper) Filter(filter FilterFunc) *DirWrapper

func (*DirWrapper) Walk added in v0.0.2

func (x *DirWrapper) Walk(next string) *DirWrapper

type ECDSA added in v0.0.2

type ECDSA struct{ *ecdsa.PrivateKey }

func (*ECDSA) Sign added in v0.0.2

func (x *ECDSA) Sign(h []byte) (r, s *big.Int, err error)

func (*ECDSA) SignASN1 added in v0.0.2

func (x *ECDSA) SignASN1(h []byte) ([]byte, error)

func (*ECDSA) Verify added in v0.0.2

func (x *ECDSA) Verify(h []byte, r, s *big.Int) bool

func (*ECDSA) VerifyASN1 added in v0.0.2

func (x *ECDSA) VerifyASN1(h, sig []byte) bool

func (*ECDSA) Write added in v0.0.2

func (x *ECDSA) Write(key, pub io.Writer) (err error)

type FilterFunc added in v0.0.2

type FilterFunc func(i int, f os.FileInfo, fs []os.FileInfo) bool

type Flate added in v0.0.2

type Flate struct {
	// contains filtered or unexported fields
}

func (*Flate) Read added in v0.0.2

func (x *Flate) Read(dst io.Writer, src io.Reader) (err error)

func (*Flate) Write added in v0.0.2

func (x *Flate) Write(dst io.Writer, src io.Reader) (err error)

type FsFileInfo

type FsFileInfo interface{ fs.FileInfo }

type GraphicsConfig added in v0.0.2

type GraphicsConfig struct {
	GIF  *gif.Options
	JPEG *jpeg.Options
	TIFF *tiff.Options
}

type GraphicsWrapper added in v0.0.2

type GraphicsWrapper struct {
	// contains filtered or unexported fields
}

func (*GraphicsWrapper) Blur added in v0.0.2

func (x *GraphicsWrapper) Blur(dst io.Writer, src io.Reader, stdDev float64, size int) (err error)

func (*GraphicsWrapper) Decode added in v0.0.2

func (x *GraphicsWrapper) Decode(src io.Reader) (img image.Image, format string, err error)

func (*GraphicsWrapper) DecodeConfig added in v0.0.2

func (x *GraphicsWrapper) DecodeConfig(src io.Reader) (conf image.Config, format string, err error)

func (*GraphicsWrapper) Encode added in v0.0.2

func (x *GraphicsWrapper) Encode(dst io.Writer, img image.Image, format string) (err error)

func (*GraphicsWrapper) Rect added in v0.0.2

func (x *GraphicsWrapper) Rect(x0, y0, x1, y1 int) image.Rectangle

func (*GraphicsWrapper) Rotate added in v0.0.2

func (x *GraphicsWrapper) Rotate(dst io.Writer, src io.Reader, angle float64) (err error)

func (*GraphicsWrapper) Scale added in v0.0.2

func (x *GraphicsWrapper) Scale(dst io.Writer, src io.Reader, w, h int) (err error)

func (*GraphicsWrapper) SubImage added in v0.0.2

func (x *GraphicsWrapper) SubImage(img image.Image, rect image.Rectangle) (sub image.Image)

func (*GraphicsWrapper) Thumbnail added in v0.0.2

func (x *GraphicsWrapper) Thumbnail(dst io.Writer, src io.Reader, w, h int) (err error)

type Gzip added in v0.0.2

type Gzip struct {
	// contains filtered or unexported fields
}

func (*Gzip) Read added in v0.0.2

func (x *Gzip) Read(dst io.Writer, src io.Reader) (err error)

func (*Gzip) Write added in v0.0.2

func (x *Gzip) Write(dst io.Writer, src io.Reader) (err error)

type HTMLTemplateWrapper added in v0.0.2

type HTMLTemplateWrapper struct {
	// contains filtered or unexported fields
}

func (*HTMLTemplateWrapper) Execute added in v0.0.2

func (x *HTMLTemplateWrapper) Execute(w io.Writer, key string, data interface{}) error

Execute receive a key as string and data (the easiest is using map[string]interface{}) key is usually a `define` keyword in your template

{{define "index"}} <html>{{.content}}</html> {{end}}

to set `.content`, send map[string]interface{}{ "content": "hello, world" }

note that set html need to convert to template.HTML, use the helper in `internal/datatype`

to set `.content`, send map[string]interface{}{ "content": datatype.HTML("<div>hello</div> <div>world</div>") }

func (*HTMLTemplateWrapper) Parse added in v0.0.2

func (x *HTMLTemplateWrapper) Parse(r ...io.Reader) error

Parse receive multiple io.Reader, this is useful for testing purpose, using strings.NewReader("pattern"), or even *os.File

type HTTPClientMock added in v0.0.2

type HTTPClientMock struct {
	*httptest.Server
	// contains filtered or unexported fields
}

func (*HTTPClientMock) Expect added in v0.0.2

func (x *HTTPClientMock) Expect(method, pattern string, handler http.Handler)
func (x *HTTPClientMock) NewRequest(method, target string, body io.Reader) *http.Request {
	return httptest.NewRequest(method, target, body)
}

func (*HTTPClientMock) URL added in v0.0.2

func (x *HTTPClientMock) URL(path string) string

type HTTPClientTrace added in v0.0.2

type HTTPClientTrace = httptrace.ClientTrace

type HTTPClientWrapper added in v0.0.2

type HTTPClientWrapper struct{ *http.Client }

type HTTPMux added in v0.0.2

type HTTPMux struct {

	// PanicHandler can access the error recovered via PanicRecoveryFromRequest,
	// PanicRecoveryFromRequest is a helper under httphandler package
	PanicHandler    http.Handler
	NotFoundHandler http.Handler
	// contains filtered or unexported fields
}

HTTPMux holds a map of entries

func (*HTTPMux) GoString added in v0.0.2

func (m *HTTPMux) GoString() string

GoString is useful for inspection by listing all its properties, also called when encountering verb %#v in fmt.fmt.Printf

func (*HTTPMux) Handle added in v0.0.2

func (m *HTTPMux) Handle(method string, pattern string, next http.Handler) *HTTPMux

Handle will register http.Handler with MuxMatcherMethods on method and MuxMatcherPattern on pattern, see more details on each mux matcher implementation

func (*HTTPMux) ServeHTTP added in v0.0.2

func (m *HTTPMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implement http.Handler interface

func (*HTTPMux) With added in v0.0.2

func (m *HTTPMux) With(next http.Handler, matcher HTTPMuxMatcher) *HTTPMux

With will register http.Handler with any implementation of MuxMatcher

type HTTPMuxMatcher added in v0.0.2

type HTTPMuxMatcher interface {
	// Test is called when MuxMatcher is added to Mux, this should be an
	// opportunity to set priority and test the implementation parameter
	// e.g. MuxMatcherPattern should check pattern, start, end
	Test() bool

	// Priority is called after Test() returning true to set a priority queue
	Priority() float64

	// Match is called by order of Priority, after its turn, it will validate
	// *http.Request and if the result is true, the http.Handler registered
	// in the entry will be served
	Match(*http.Request) bool

	// fmt.GoStringer is useful inspection methods, e.g. comparing parameter
	// or priority
	fmt.GoStringer

	// json.Marshaler and json.Unmarshaler should be supported too, in order to
	// build the MuxMatcher based on config
	json.Marshaler
}

HTTPMuxMatcher is an incoming *http.Request matcher

type HTTPReverseProxy added in v0.0.2

type HTTPReverseProxy = httputil.ReverseProxy

type HTTPServerWrapper added in v0.0.2

type HTTPServerWrapper struct{ *http.Server }

func (HTTPServerWrapper) Run added in v0.0.2

func (x HTTPServerWrapper) Run(onInfo func(string), onError func(error), shutdownTimeout time.Duration) error

Run is extended method that wrap `ListenAndServe` and `ListenAndServeTLS` together and supposedly doing a graceful shutdown

type HTTPTransportWrapper added in v0.0.2

type HTTPTransportWrapper struct {
	// contains filtered or unexported fields
}

HTTPTransportWrapper implement http.RoundTripper, with 3 useful fields

- Trace (*httptrace.ClientTrace) one can use `HTTPTrace` directly an modify its fields

- RequestFn callback when creating *http.Request

- ResponseFn callback when receiving *http.Response

func (HTTPTransportWrapper) DumpOnRequest added in v0.0.2

func (x HTTPTransportWrapper) DumpOnRequest(dst io.Writer, includeBody bool) HTTPTransportWrapper

func (HTTPTransportWrapper) DumpOnResponse added in v0.0.2

func (x HTTPTransportWrapper) DumpOnResponse(dst io.Writer, includeBody bool) HTTPTransportWrapper

func (HTTPTransportWrapper) OnRequest added in v0.0.2

func (HTTPTransportWrapper) OnResponse added in v0.0.2

func (HTTPTransportWrapper) RoundTrip added in v0.0.2

func (x HTTPTransportWrapper) RoundTrip(req *http.Request) (res *http.Response, err error)

func (HTTPTransportWrapper) WithBase added in v0.0.2

func (HTTPTransportWrapper) WithTrace added in v0.0.2

type List

type List []interface{}

List extends `[]interface{}`, and it should be used to represent json-like data

func (*List) Add

func (l *List) Add(v interface{})

func (*List) Delete

func (l *List) Delete(k int)

func (*List) Map

func (l *List) Map(fn func(k int, v interface{}))

type LogConfig added in v0.0.2

type LogConfig struct {
	Prefix string
	Flag   int
	// contains filtered or unexported fields
}

func (*LogConfig) ConsoleWriter added in v0.0.2

func (c *LogConfig) ConsoleWriter(cw *ConsoleWriter) *LogConfig

func (*LogConfig) MultiWriter added in v0.0.2

func (c *LogConfig) MultiWriter(w ...io.Writer) *LogConfig

type LogWrapper added in v0.0.2

type LogWrapper struct {
	// Logger is a default *log.Logger instance
	*log.Logger
	// contains filtered or unexported fields
}

LogWrapper implement all the methods of *log.Logger also accessible from .Logger

LogWrapper also have extension via .Z to access more robust logging experience using zerolog

func (*LogWrapper) UseErrorStackMarshaler added in v0.0.2

func (x *LogWrapper) UseErrorStackMarshaler(use bool) *LogWrapper

func (*LogWrapper) Z added in v0.0.2

func (x *LogWrapper) Z(levelStr string) *zerolog.Event

type Minify added in v0.0.2

type Minify struct {
	// contains filtered or unexported fields
}

func (*Minify) WithMediaType added in v0.0.2

func (x *Minify) WithMediaType(mediatype string) *Minify

func (*Minify) Write added in v0.0.2

func (x *Minify) Write(dst io.Writer, src io.Reader) (err error)

type MockFsFileInfo

type MockFsFileInfo struct {
	// contains filtered or unexported fields
}

MockFsFileInfo is a mock of FsFileInfo interface.

func NewMockFsFileInfo

func NewMockFsFileInfo(ctrl *gomock.Controller) *MockFsFileInfo

NewMockFsFileInfo creates a new mock instance.

func (*MockFsFileInfo) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFsFileInfo) IsDir

func (m *MockFsFileInfo) IsDir() bool

IsDir mocks base method.

func (*MockFsFileInfo) ModTime

func (m *MockFsFileInfo) ModTime() time.Time

ModTime mocks base method.

func (*MockFsFileInfo) Mode

func (m *MockFsFileInfo) Mode() fs.FileMode

Mode mocks base method.

func (*MockFsFileInfo) Name

func (m *MockFsFileInfo) Name() string

Name mocks base method.

func (*MockFsFileInfo) Size

func (m *MockFsFileInfo) Size() int64

Size mocks base method.

func (*MockFsFileInfo) Sys

func (m *MockFsFileInfo) Sys() interface{}

Sys mocks base method.

type MockFsFileInfoMockRecorder

type MockFsFileInfoMockRecorder struct {
	// contains filtered or unexported fields
}

MockFsFileInfoMockRecorder is the mock recorder for MockFsFileInfo.

func (*MockFsFileInfoMockRecorder) IsDir

func (mr *MockFsFileInfoMockRecorder) IsDir() *gomock.Call

IsDir indicates an expected call of IsDir.

func (*MockFsFileInfoMockRecorder) ModTime

func (mr *MockFsFileInfoMockRecorder) ModTime() *gomock.Call

ModTime indicates an expected call of ModTime.

func (*MockFsFileInfoMockRecorder) Mode

Mode indicates an expected call of Mode.

func (*MockFsFileInfoMockRecorder) Name

Name indicates an expected call of Name.

func (*MockFsFileInfoMockRecorder) Size

Size indicates an expected call of Size.

func (*MockFsFileInfoMockRecorder) Sys

Sys indicates an expected call of Sys.

type MockNetAddr

type MockNetAddr struct {
	// contains filtered or unexported fields
}

MockNetAddr is a mock of NetAddr interface.

func NewMockNetAddr

func NewMockNetAddr(ctrl *gomock.Controller) *MockNetAddr

NewMockNetAddr creates a new mock instance.

func (*MockNetAddr) EXPECT

func (m *MockNetAddr) EXPECT() *MockNetAddrMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNetAddr) Network

func (m *MockNetAddr) Network() string

Network mocks base method.

func (*MockNetAddr) String

func (m *MockNetAddr) String() string

String mocks base method.

type MockNetAddrMockRecorder

type MockNetAddrMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetAddrMockRecorder is the mock recorder for MockNetAddr.

func (*MockNetAddrMockRecorder) Network

func (mr *MockNetAddrMockRecorder) Network() *gomock.Call

Network indicates an expected call of Network.

func (*MockNetAddrMockRecorder) String

func (mr *MockNetAddrMockRecorder) String() *gomock.Call

String indicates an expected call of String.

type MockNetConn

type MockNetConn struct {
	// contains filtered or unexported fields
}

MockNetConn is a mock of NetConn interface.

func NewMockNetConn

func NewMockNetConn(ctrl *gomock.Controller) *MockNetConn

NewMockNetConn creates a new mock instance.

func (*MockNetConn) Close

func (m *MockNetConn) Close() error

Close mocks base method.

func (*MockNetConn) EXPECT

func (m *MockNetConn) EXPECT() *MockNetConnMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNetConn) LocalAddr

func (m *MockNetConn) LocalAddr() net.Addr

LocalAddr mocks base method.

func (*MockNetConn) Read

func (m *MockNetConn) Read(b []byte) (int, error)

Read mocks base method.

func (*MockNetConn) RemoteAddr

func (m *MockNetConn) RemoteAddr() net.Addr

RemoteAddr mocks base method.

func (*MockNetConn) SetDeadline

func (m *MockNetConn) SetDeadline(t time.Time) error

SetDeadline mocks base method.

func (*MockNetConn) SetReadDeadline

func (m *MockNetConn) SetReadDeadline(t time.Time) error

SetReadDeadline mocks base method.

func (*MockNetConn) SetWriteDeadline

func (m *MockNetConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline mocks base method.

func (*MockNetConn) Write

func (m *MockNetConn) Write(b []byte) (int, error)

Write mocks base method.

type MockNetConnMockRecorder

type MockNetConnMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetConnMockRecorder is the mock recorder for MockNetConn.

func (*MockNetConnMockRecorder) Close

func (mr *MockNetConnMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockNetConnMockRecorder) LocalAddr

func (mr *MockNetConnMockRecorder) LocalAddr() *gomock.Call

LocalAddr indicates an expected call of LocalAddr.

func (*MockNetConnMockRecorder) Read

func (mr *MockNetConnMockRecorder) Read(b interface{}) *gomock.Call

Read indicates an expected call of Read.

func (*MockNetConnMockRecorder) RemoteAddr

func (mr *MockNetConnMockRecorder) RemoteAddr() *gomock.Call

RemoteAddr indicates an expected call of RemoteAddr.

func (*MockNetConnMockRecorder) SetDeadline

func (mr *MockNetConnMockRecorder) SetDeadline(t interface{}) *gomock.Call

SetDeadline indicates an expected call of SetDeadline.

func (*MockNetConnMockRecorder) SetReadDeadline

func (mr *MockNetConnMockRecorder) SetReadDeadline(t interface{}) *gomock.Call

SetReadDeadline indicates an expected call of SetReadDeadline.

func (*MockNetConnMockRecorder) SetWriteDeadline

func (mr *MockNetConnMockRecorder) SetWriteDeadline(t interface{}) *gomock.Call

SetWriteDeadline indicates an expected call of SetWriteDeadline.

func (*MockNetConnMockRecorder) Write

func (mr *MockNetConnMockRecorder) Write(b interface{}) *gomock.Call

Write indicates an expected call of Write.

type MockNetDialer

type MockNetDialer struct {
	// contains filtered or unexported fields
}

MockNetDialer is a mock of NetDialer interface.

func NewMockNetDialer

func NewMockNetDialer(ctrl *gomock.Controller) *MockNetDialer

NewMockNetDialer creates a new mock instance.

func (*MockNetDialer) Dial

func (m *MockNetDialer) Dial(network, address string) (net.Conn, error)

Dial mocks base method.

func (*MockNetDialer) DialContext

func (m *MockNetDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext mocks base method.

func (*MockNetDialer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockNetDialerMockRecorder

type MockNetDialerMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetDialerMockRecorder is the mock recorder for MockNetDialer.

func (*MockNetDialerMockRecorder) Dial

func (mr *MockNetDialerMockRecorder) Dial(network, address interface{}) *gomock.Call

Dial indicates an expected call of Dial.

func (*MockNetDialerMockRecorder) DialContext

func (mr *MockNetDialerMockRecorder) DialContext(ctx, network, address interface{}) *gomock.Call

DialContext indicates an expected call of DialContext.

type MockNetResolver

type MockNetResolver struct {
	// contains filtered or unexported fields
}

MockNetResolver is a mock of NetResolver interface.

func NewMockNetResolver

func NewMockNetResolver(ctrl *gomock.Controller) *MockNetResolver

NewMockNetResolver creates a new mock instance.

func (*MockNetResolver) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNetResolver) LookupAddr

func (m *MockNetResolver) LookupAddr(ctx context.Context, addr string) ([]string, error)

LookupAddr mocks base method.

func (*MockNetResolver) LookupCNAME

func (m *MockNetResolver) LookupCNAME(ctx context.Context, host string) (string, error)

LookupCNAME mocks base method.

func (*MockNetResolver) LookupHost

func (m *MockNetResolver) LookupHost(ctx context.Context, host string) ([]string, error)

LookupHost mocks base method.

func (*MockNetResolver) LookupIP

func (m *MockNetResolver) LookupIP(ctx context.Context, network, host string) ([]net.IP, error)

LookupIP mocks base method.

func (*MockNetResolver) LookupIPAddr

func (m *MockNetResolver) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)

LookupIPAddr mocks base method.

func (*MockNetResolver) LookupMX

func (m *MockNetResolver) LookupMX(ctx context.Context, name string) ([]*net.MX, error)

LookupMX mocks base method.

func (*MockNetResolver) LookupNS

func (m *MockNetResolver) LookupNS(ctx context.Context, name string) ([]*net.NS, error)

LookupNS mocks base method.

func (*MockNetResolver) LookupPort

func (m *MockNetResolver) LookupPort(ctx context.Context, network, service string) (int, error)

LookupPort mocks base method.

func (*MockNetResolver) LookupSRV

func (m *MockNetResolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error)

LookupSRV mocks base method.

func (*MockNetResolver) LookupTXT

func (m *MockNetResolver) LookupTXT(ctx context.Context, name string) ([]string, error)

LookupTXT mocks base method.

type MockNetResolverMockRecorder

type MockNetResolverMockRecorder struct {
	// contains filtered or unexported fields
}

MockNetResolverMockRecorder is the mock recorder for MockNetResolver.

func (*MockNetResolverMockRecorder) LookupAddr

func (mr *MockNetResolverMockRecorder) LookupAddr(ctx, addr interface{}) *gomock.Call

LookupAddr indicates an expected call of LookupAddr.

func (*MockNetResolverMockRecorder) LookupCNAME

func (mr *MockNetResolverMockRecorder) LookupCNAME(ctx, host interface{}) *gomock.Call

LookupCNAME indicates an expected call of LookupCNAME.

func (*MockNetResolverMockRecorder) LookupHost

func (mr *MockNetResolverMockRecorder) LookupHost(ctx, host interface{}) *gomock.Call

LookupHost indicates an expected call of LookupHost.

func (*MockNetResolverMockRecorder) LookupIP

func (mr *MockNetResolverMockRecorder) LookupIP(ctx, network, host interface{}) *gomock.Call

LookupIP indicates an expected call of LookupIP.

func (*MockNetResolverMockRecorder) LookupIPAddr

func (mr *MockNetResolverMockRecorder) LookupIPAddr(ctx, host interface{}) *gomock.Call

LookupIPAddr indicates an expected call of LookupIPAddr.

func (*MockNetResolverMockRecorder) LookupMX

func (mr *MockNetResolverMockRecorder) LookupMX(ctx, name interface{}) *gomock.Call

LookupMX indicates an expected call of LookupMX.

func (*MockNetResolverMockRecorder) LookupNS

func (mr *MockNetResolverMockRecorder) LookupNS(ctx, name interface{}) *gomock.Call

LookupNS indicates an expected call of LookupNS.

func (*MockNetResolverMockRecorder) LookupPort

func (mr *MockNetResolverMockRecorder) LookupPort(ctx, network, service interface{}) *gomock.Call

LookupPort indicates an expected call of LookupPort.

func (*MockNetResolverMockRecorder) LookupSRV

func (mr *MockNetResolverMockRecorder) LookupSRV(ctx, service, proto, name interface{}) *gomock.Call

LookupSRV indicates an expected call of LookupSRV.

func (*MockNetResolverMockRecorder) LookupTXT

func (mr *MockNetResolverMockRecorder) LookupTXT(ctx, name interface{}) *gomock.Call

LookupTXT indicates an expected call of LookupTXT.

type MockSmtpClient

type MockSmtpClient struct {
	// contains filtered or unexported fields
}

MockSmtpClient is a mock of SmtpClient interface.

func NewMockSmtpClient

func NewMockSmtpClient(ctrl *gomock.Controller) *MockSmtpClient

NewMockSmtpClient creates a new mock instance.

func (*MockSmtpClient) Auth

func (m *MockSmtpClient) Auth(a smtp.Auth) error

Auth mocks base method.

func (*MockSmtpClient) Close

func (m *MockSmtpClient) Close() error

Close mocks base method.

func (*MockSmtpClient) Data

func (m *MockSmtpClient) Data() (io.WriteCloser, error)

Data mocks base method.

func (*MockSmtpClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSmtpClient) Extension

func (m *MockSmtpClient) Extension(ext string) (bool, string)

Extension mocks base method.

func (*MockSmtpClient) Hello

func (m *MockSmtpClient) Hello(localName string) error

Hello mocks base method.

func (*MockSmtpClient) Mail

func (m *MockSmtpClient) Mail(from string) error

Mail mocks base method.

func (*MockSmtpClient) Noop

func (m *MockSmtpClient) Noop() error

Noop mocks base method.

func (*MockSmtpClient) Quit

func (m *MockSmtpClient) Quit() error

Quit mocks base method.

func (*MockSmtpClient) Rcpt

func (m *MockSmtpClient) Rcpt(to string) error

Rcpt mocks base method.

func (*MockSmtpClient) Reset

func (m *MockSmtpClient) Reset() error

Reset mocks base method.

func (*MockSmtpClient) StartTLS

func (m *MockSmtpClient) StartTLS(config *tls.Config) error

StartTLS mocks base method.

func (*MockSmtpClient) TLSConnectionState

func (m *MockSmtpClient) TLSConnectionState() (tls.ConnectionState, bool)

TLSConnectionState mocks base method.

func (*MockSmtpClient) Verify

func (m *MockSmtpClient) Verify(addr string) error

Verify mocks base method.

type MockSmtpClientMockRecorder

type MockSmtpClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockSmtpClientMockRecorder is the mock recorder for MockSmtpClient.

func (*MockSmtpClientMockRecorder) Auth

func (mr *MockSmtpClientMockRecorder) Auth(a interface{}) *gomock.Call

Auth indicates an expected call of Auth.

func (*MockSmtpClientMockRecorder) Close

func (mr *MockSmtpClientMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockSmtpClientMockRecorder) Data

Data indicates an expected call of Data.

func (*MockSmtpClientMockRecorder) Extension

func (mr *MockSmtpClientMockRecorder) Extension(ext interface{}) *gomock.Call

Extension indicates an expected call of Extension.

func (*MockSmtpClientMockRecorder) Hello

func (mr *MockSmtpClientMockRecorder) Hello(localName interface{}) *gomock.Call

Hello indicates an expected call of Hello.

func (*MockSmtpClientMockRecorder) Mail

func (mr *MockSmtpClientMockRecorder) Mail(from interface{}) *gomock.Call

Mail indicates an expected call of Mail.

func (*MockSmtpClientMockRecorder) Noop

Noop indicates an expected call of Noop.

func (*MockSmtpClientMockRecorder) Quit

Quit indicates an expected call of Quit.

func (*MockSmtpClientMockRecorder) Rcpt

func (mr *MockSmtpClientMockRecorder) Rcpt(to interface{}) *gomock.Call

Rcpt indicates an expected call of Rcpt.

func (*MockSmtpClientMockRecorder) Reset

func (mr *MockSmtpClientMockRecorder) Reset() *gomock.Call

Reset indicates an expected call of Reset.

func (*MockSmtpClientMockRecorder) StartTLS

func (mr *MockSmtpClientMockRecorder) StartTLS(config interface{}) *gomock.Call

StartTLS indicates an expected call of StartTLS.

func (*MockSmtpClientMockRecorder) TLSConnectionState

func (mr *MockSmtpClientMockRecorder) TLSConnectionState() *gomock.Call

TLSConnectionState indicates an expected call of TLSConnectionState.

func (*MockSmtpClientMockRecorder) Verify

func (mr *MockSmtpClientMockRecorder) Verify(addr interface{}) *gomock.Call

Verify indicates an expected call of Verify.

type NaCl added in v0.0.2

type NaCl struct{}

func (*NaCl) AuthSum added in v0.0.2

func (*NaCl) AuthSum(message []byte, secretKey *[32]byte) []byte

func (*NaCl) AuthVerify added in v0.0.2

func (*NaCl) AuthVerify(digest []byte, message []byte, secretKey *[32]byte) bool

func (*NaCl) BoxKeyPair added in v0.0.2

func (*NaCl) BoxKeyPair() (publicKey, privateKey *[32]byte, err error)

func (*NaCl) BoxOpen added in v0.0.2

func (*NaCl) BoxOpen(box_ []byte, peersPublicKey, privateKey *[32]byte) ([]byte, bool)

func (*NaCl) BoxOpenAfterPrecomputation added in v0.0.2

func (*NaCl) BoxOpenAfterPrecomputation(box_ []byte, sharedKey *[32]byte) ([]byte, bool)

func (*NaCl) BoxOpenAnonymous added in v0.0.2

func (*NaCl) BoxOpenAnonymous(box_ []byte, publicKey, privateKey *[32]byte) (message []byte, ok bool)

func (*NaCl) BoxPrecompute added in v0.0.2

func (*NaCl) BoxPrecompute(peersPublicKey, privateKey *[32]byte) (sharedKey *[32]byte)

func (*NaCl) BoxSeal added in v0.0.2

func (*NaCl) BoxSeal(message []byte, peersPublicKey, privateKey *[32]byte) []byte

func (*NaCl) BoxSealAfterPrecomputation added in v0.0.2

func (*NaCl) BoxSealAfterPrecomputation(message []byte, sharedKey *[32]byte) []byte

func (*NaCl) BoxSealAnonymous added in v0.0.2

func (*NaCl) BoxSealAnonymous(message []byte, recipient *[32]byte) ([]byte, error)

func (*NaCl) SecretBoxOpen added in v0.0.2

func (*NaCl) SecretBoxOpen(box_ []byte, key *[32]byte) ([]byte, bool)

func (*NaCl) SecretBoxSeal added in v0.0.2

func (*NaCl) SecretBoxSeal(message []byte, key *[32]byte) []byte

func (*NaCl) Sign added in v0.0.2

func (*NaCl) Sign(message []byte, privateKey *[64]byte) []byte

func (*NaCl) SignKeyPair added in v0.0.2

func (*NaCl) SignKeyPair() (publicKey *[32]byte, privateKey *[64]byte, err error)

func (*NaCl) SignOpen added in v0.0.2

func (*NaCl) SignOpen(signedMessage []byte, publicKey *[32]byte) ([]byte, bool)

type NetAddr

type NetAddr interface{ net.Addr }

type NetConn

type NetConn interface{ net.Conn }

type NetDialer

type NetDialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
	Dial(network, address string) (net.Conn, error)
}

type NetResolver

type NetResolver interface {
	LookupHost(ctx context.Context, host string) (addrs []string, err error)
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
	LookupIP(ctx context.Context, network, host string) ([]net.IP, error)
	LookupPort(ctx context.Context, network, service string) (port int, err error)
	LookupCNAME(ctx context.Context, host string) (cname string, err error)
	LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
	LookupMX(ctx context.Context, name string) ([]*net.MX, error)
	LookupNS(ctx context.Context, name string) ([]*net.NS, error)
	LookupTXT(ctx context.Context, name string) ([]string, error)
	LookupAddr(ctx context.Context, addr string) (names []string, err error)
}

type NetSMTPMock added in v0.0.2

type NetSMTPMock struct {
	// contains filtered or unexported fields
}

func (*NetSMTPMock) WithNetDialer added in v0.0.2

func (x *NetSMTPMock) WithNetDialer(netDialer NetDialer)

func (*NetSMTPMock) WithNetResolver added in v0.0.2

func (x *NetSMTPMock) WithNetResolver(netResolver NetResolver)

func (*NetSMTPMock) WithNewSmtpClient added in v0.0.2

func (x *NetSMTPMock) WithNewSmtpClient(client SmtpClient, err error)

func (*NetSMTPMock) WithSendMail added in v0.0.2

func (x *NetSMTPMock) WithSendMail(err error)

type NetSMTPWrapper added in v0.0.2

type NetSMTPWrapper struct {
	// contains filtered or unexported fields
}

func (*NetSMTPWrapper) ReverseLookup added in v0.0.2

func (x *NetSMTPWrapper) ReverseLookup(ctx context.Context, from, to mail.Address) (err error)

func (*NetSMTPWrapper) SendMail added in v0.0.2

func (x *NetSMTPWrapper) SendMail(ctx context.Context, id string, from, to mail.Address, subject string, plain, html []byte) error

type PrometheusConfig added in v0.0.2

type PrometheusConfig struct {
	Namespace string
	Subsystem string
}

type PrometheusMock added in v0.0.2

type PrometheusMock struct{}

func (*PrometheusMock) CollectAndCompare added in v0.0.2

func (p *PrometheusMock) CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error

func (*PrometheusMock) CollectAndCount added in v0.0.2

func (p *PrometheusMock) CollectAndCount(c prometheus.Collector, metricNames ...string) int

func (*PrometheusMock) CollectAndLint added in v0.0.2

func (p *PrometheusMock) CollectAndLint(c prometheus.Collector, metricNames ...string) ([]promlint.Problem, error)

func (*PrometheusMock) ToFloat64 added in v0.0.2

func (p *PrometheusMock) ToFloat64(c prometheus.Collector) float64

type PrometheusWrapper added in v0.0.2

type PrometheusWrapper struct {
	// contains filtered or unexported fields
}

func (*PrometheusWrapper) CounterVec added in v0.0.2

func (p *PrometheusWrapper) CounterVec(name, help string, labelNames ...string) *prometheus.CounterVec

func (*PrometheusWrapper) GaugeVec added in v0.0.2

func (p *PrometheusWrapper) GaugeVec(name, help string, labelNames ...string) *prometheus.GaugeVec

func (*PrometheusWrapper) HistogramVec added in v0.0.2

func (p *PrometheusWrapper) HistogramVec(name, help string, labelNames ...string) *prometheus.HistogramVec

func (*PrometheusWrapper) SummaryVec added in v0.0.2

func (p *PrometheusWrapper) SummaryVec(name, help string, labelNames ...string) *prometheus.SummaryVec

type RSA added in v0.0.2

type RSA struct{ *rsa.PrivateKey }

func (*RSA) DecryptOAEP added in v0.0.2

func (x *RSA) DecryptOAEP(ciphertext, label []byte) ([]byte, error)

func (*RSA) DecryptPKCS1v15 added in v0.0.2

func (x *RSA) DecryptPKCS1v15(ciphertext []byte) ([]byte, error)

func (*RSA) EncryptOAEP added in v0.0.2

func (x *RSA) EncryptOAEP(msg, label []byte) ([]byte, error)

func (*RSA) EncryptPKCS1v15 added in v0.0.2

func (x *RSA) EncryptPKCS1v15(msg []byte) ([]byte, error)

func (*RSA) Write added in v0.0.2

func (x *RSA) Write(key, pub io.Writer) (err error)

type RedisConfig added in v0.0.2

type RedisConfig = redis.UniversalOptions

type RedisMock added in v0.0.2

type RedisMock struct{ redismock.ClientMock }

type RedisWrapper added in v0.0.2

type RedisWrapper struct{ redis.UniversalClient }

type RistrettoCacheI added in v0.0.2

type RistrettoCacheI interface {
	Clear()
	Close()
	Del(key interface{})
	Get(key interface{}) (interface{}, bool)
	Set(key, value interface{}, cost int64) bool
	SetWithTTL(key, value interface{}, cost int64, ttl time.Duration) bool
}

type RistrettoCacheMetricsI added in v0.0.2

type RistrettoCacheMetricsI interface {
	Clear()
	CostAdded() uint64
	CostEvicted() uint64
	GetsDropped() uint64
	GetsKept() uint64
	Hits() uint64
	KeysAdded() uint64
	KeysEvicted() uint64
	KeysUpdated() uint64
	Misses() uint64
	Ratio() float64
	SetsDropped() uint64
	SetsRejected() uint64
	String() string
}

type RistrettoConfig added in v0.0.2

type RistrettoConfig = ristretto.Config

type RistrettoWrapper added in v0.0.2

type RistrettoWrapper struct{ *ristretto.Cache }

type SMTPConfig added in v0.0.2

type SMTPConfig struct {
	PlainAuthIdentity   string
	PlainAuthUsername   string
	PlainAuthPassword   string
	CRAMMD5AuthUsername string
	CRAMMD5AuthSecret   string
	Addr                string
}

type SQLConfig added in v0.0.2

type SQLConfig struct {
	DriverName      string
	DataSourceName  string
	ConnMaxIdleTime time.Duration
	ConnMaxLifetime time.Duration
	MaxIdleConns    int
	MaxOpenConns    int
}

type SQLMock added in v0.0.2

type SQLMock struct{ sqlmock.Sqlmock }

func (SQLMock) NewResult added in v0.0.2

func (m SQLMock) NewResult(lastInsertId int64, lastInsertIdError error, rowsAffected int64, rowsAffectedError error) sql.Result

func (SQLMock) NewRows added in v0.0.2

func (m SQLMock) NewRows(columns ...string) *sqlmock.Rows

type SQLResultExec added in v0.0.2

type SQLResultExec struct{ sql.Result }

type SQLResultQuery added in v0.0.2

type SQLResultQuery []Dict

type SQLResultQueryRow added in v0.0.2

type SQLResultQueryRow Dict

type SQLStatement added in v0.0.2

type SQLStatement struct {
	// contains filtered or unexported fields
}

func (SQLStatement) Exec added in v0.0.2

func (s SQLStatement) Exec(ctx context.Context, args ...interface{}) (res SQLResultExec, err error)

Exec

func (SQLStatement) Query added in v0.0.2

func (s SQLStatement) Query(ctx context.Context, args ...interface{}) (rows SQLResultQuery, err error)

Query

func (SQLStatement) QueryRow added in v0.0.2

func (s SQLStatement) QueryRow(ctx context.Context, args ...interface{}) (row SQLResultQueryRow, err error)

QueryRow

type SQLWrapper added in v0.0.2

type SQLWrapper struct {
	*sql.DB
	// contains filtered or unexported fields
}

func (*SQLWrapper) Done added in v0.0.2

func (s *SQLWrapper) Done(tx *sql.Tx, err error) error

Done should validate any tx transaction with it's err, should the err is empty then do the Commit, if any err occured then do the Rollback

func (*SQLWrapper) Statement added in v0.0.2

func (s *SQLWrapper) Statement(ctx context.Context, tx *sql.Tx, q string) SQLStatement

Statement will cached a prepared statement on next identical query

type SmtpClient

type SmtpClient interface {
	Close() error
	Hello(localName string) error
	StartTLS(config *tls.Config) error
	TLSConnectionState() (state tls.ConnectionState, ok bool)
	Verify(addr string) error
	Auth(a smtp.Auth) error
	Mail(from string) error
	Rcpt(to string) error
	Data() (io.WriteCloser, error)
	Extension(ext string) (bool, string)
	Reset() error
	Noop() error
	Quit() error
}

type TextTemplateWrapper added in v0.0.2

type TextTemplateWrapper struct {
	// contains filtered or unexported fields
}

func (*TextTemplateWrapper) Execute added in v0.0.2

func (x *TextTemplateWrapper) Execute(w io.Writer, key string, data interface{}) error

Execute receive a key as string and data (the easiest is using map[string]interface{}) key is usually a `define` keyword in your template

{{define "index"}} <html>{{.content}}</html> {{end}}

to set `.content`, send map[string]interface{}{ "content": "hello, world" }

note that set html need to convert to template.HTML, use the helper in `internal/datatype`

to set `.content`, send map[string]interface{}{ "content": datatype.HTML("<div>hello</div> <div>world</div>") }

func (*TextTemplateWrapper) Parse added in v0.0.2

func (x *TextTemplateWrapper) Parse(r ...io.Reader) error

Parse receive multiple io.Reader, this is useful for testing purpose, using strings.NewReader("pattern"), or even *os.File

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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