mft

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 6 Imported by: 30

README

mft

some tools (golang) G - generator next id

Error

You can create error with code and error from error

Example:

package main
import (
	"fmt"
	"github.com/myfantasy/mft"
)
func main() {
	var e error
	e = mft.ErrorCS(7, "Bond Error")
	fmt.Println(e)
	e = mft.ErrorCSE(12, "M Error", e)
	fmt.Println(e)
}
[7] Bond Error
[12] M Error    [7] Bond Error

Documentation

Index

Constants

View Source
const ErrorCommonCode int = 50000

ErrorCommonCode - no code error

Variables

View Source
var FillCallStack bool = false
View Source
var InnerErrorPrefix string = "  "

Functions

func GetStack added in v0.2.0

func GetStack() string

func RvGet

func RvGet() int64

RvGet - Generate Next RV (sync)

func RvGetPart

func RvGetPart() int64

RvGetPart - Generate Next RV (sync)

Types

type Error

type Error struct {
	Code              int      `json:"code,omitempty"`
	Msg               string   `json:"msg,omitempty"`
	InternalErrorText string   `json:"iet,omitempty"`
	InternalError     *Error   `json:"ie,omitempty"`
	InternalErrors    []*Error `json:"ies,omitempty"`
	CallStack         string   `json:"call_stack,omitempty"`
}

Error type with internal

func ErrorCE

func ErrorCE(code int, err error) *Error

ErrorCE make Error from any error

func ErrorCS

func ErrorCS(code int, err string) *Error

ErrorCS make Error from string

func ErrorCSE

func ErrorCSE(code int, err string, internalError error) *Error

ErrorCSE make Error from string with internal error

func ErrorCSEf added in v0.1.2

func ErrorCSEf(code int, internalError error, format string, a ...interface{}) *Error

ErrorCSEf make Error from string with internal error

func ErrorCSf added in v0.1.2

func ErrorCSf(code int, format string, a ...interface{}) *Error

ErrorCSf make Error from string

func ErrorE

func ErrorE(err error) *Error

ErrorE make Error from any error

func ErrorNew

func ErrorNew(msg string, internalError error) *Error

ErrorNew - Create new Error from msg and another error

func ErrorNew2

func ErrorNew2(msg string, internalError error, internal2Error error) *Error

ErrorNew2 - Create new Error

func ErrorNew2f added in v0.1.2

func ErrorNew2f(internalError error, internal2Error error, format string, a ...interface{}) *Error

ErrorNew2f - Create new Error

func ErrorNewf added in v0.1.2

func ErrorNewf(internalError error, format string, a ...interface{}) *Error

ErrorNewf - Create new Error from msg and another error

func ErrorS

func ErrorS(err string) *Error

ErrorS make Error from string

func ErrorSf added in v0.1.2

func ErrorSf(format string, a ...interface{}) *Error

ErrorSf make Error from string

func (*Error) AppendE

func (e *Error) AppendE(errs error) *Error

AppendE append next error level saving code

func (*Error) AppendList added in v0.2.0

func (e *Error) AppendList(sub ...*Error) (eOut *Error)

func (*Error) AppendS

func (e *Error) AppendS(errs string) *Error

AppendS append next error level saving code

func (*Error) AppendSf added in v0.1.2

func (e *Error) AppendSf(format string, a ...interface{}) *Error

AppendSf append next error level saving code

func (*Error) Error

func (e *Error) Error() string

Error implement error interface

type ErrorProvider

type ErrorProvider interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugln(args ...interface{})
	Infoln(args ...interface{})
	Warningln(args ...interface{})
	Errorln(args ...interface{})
	Fatalln(args ...interface{})
	Panicln(args ...interface{})
}

ErrorProvider interface for error provider mostly for background processes

type G

type G struct {
	AddValue int64
	// contains filtered or unexported fields
}

G Generator

var GlobalGenerator G

func (*G) RvGet

func (g *G) RvGet() int64

RvGet2 - Generate Next RV (sync)

func (*G) RvGetPart

func (g *G) RvGetPart() int64

RvGetPart - Generate Next RV (sync) partitioned by (x%10000)/10

Directories

Path Synopsis
Package im - int math simple operations lake max min etc for int
Package im - int math simple operations lake max min etc for int

Jump to

Keyboard shortcuts

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