common

package
v0.0.0-...-76b4f34 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyReg       = regexp.MustCompile(keyRegex)
	FilterReg    = regexp.MustCompile(filterRegex)
	SelectionReg = regexp.MustCompile(selectionRegex)
	CountReg     = regexp.MustCompile(countRegex)
	SliceReg     = regexp.MustCompile(sliceRegex)
)
View Source
var Conf = &JPathConf{
	Expr:     ".",
	Unwrap:   false,
	Table:    false,
	Compress: false,
	Indent:   2,
	Channel:  make(chan []byte, 1000),
	Headers:  nil,
}
View Source
var ErrorMessage = map[ErrorCode]string{
	Success:          "",
	InvalidJson:      "invalid json, aborting",
	InvalidExpr:      "invalid expression, aborting",
	FileError:        "file not json or unreadable, aborting",
	UnknownDataType:  "unknown data type in json object",
	UnmarshalError:   "error while unmarshalling json into map",
	UnprintableData:  "data not printable",
	UnprintableTable: "data not printable in a table format, use without -t option",
	NumberError:      "not a number",
}

Functions

func ExitWithError

func ExitWithError(code ErrorCode)

func ExitWithMessage

func ExitWithMessage(msg string)

func Tokenize

func Tokenize(json []byte) ([][]byte, error)

func WrapIntoArray

func WrapIntoArray(json [][]byte) []byte

Types

type ErrorCode

type ErrorCode int
const (
	Success ErrorCode = iota
	InvalidJson
	InvalidExpr
	FileError
	UnknownDataType
	UnmarshalError
	UnprintableData
	UnprintableTable
	NumberError
)

func (ErrorCode) Error

func (e ErrorCode) Error() error

func (ErrorCode) ExitWithMessage

func (e ErrorCode) ExitWithMessage()

func (ErrorCode) GetMsg

func (e ErrorCode) GetMsg() string

type JPathConf

type JPathConf struct {
	Expr     string
	Unwrap   bool
	Table    bool
	Compress bool
	Indent   int
	Channel  chan []byte
	Wg       sync.WaitGroup
	Headers  []string
}

Jump to

Keyboard shortcuts

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