parser

package module
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 6 Imported by: 2

README

Noob-Parser

Go Reference GitHub go.mod Go version (subdirectory of monorepo) GitHub release (latest by date)

Noob Parser is a tools to parser Primitive types, such as:

  • String masking
  • Cast String to Array of String
  • Cast String to Array of Int
  • Cast String to Bool & Vice Versa
  • Cast String to Int & Vice Versa
  • Cast Int to Bool & Vice Versa
  • Cast []int32 to []int & Vice Versa
  • Cast []int64 to []int & Vice Versa

Contents

Installation

To install this package, you need to install Go (version 1.17+ is required) & initiate your Go workspace first.

  1. After you initiate your workspace then you can install this package with below command.
go get -u github.com/alfarih31/nb-go-parser
  1. Import it in your code
import "github.com/alfarih31/nb-go-parser"

Quick Start & Usage

See the test:

Contributors

License

This project is licensed under the - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOptArg added in v1.0.4

func GetOptArg(opts []interface{}, defaultValue ...interface{}) interface{}

func GetOptBoolArg added in v1.0.4

func GetOptBoolArg(opts []bool, defaultValue ...bool) bool

func GetOptInt32Arg added in v1.0.5

func GetOptInt32Arg(opts []int32, defaultValue ...int32) int32

func GetOptInt64Arg added in v1.0.5

func GetOptInt64Arg(opts []int64, defaultValue ...int64) int64

func GetOptIntArg added in v1.0.4

func GetOptIntArg(opts []int, defaultValue ...int) int

func GetOptStringArg added in v1.0.4

func GetOptStringArg(opts []string, defaultValue ...string) string

func UIntPtr added in v1.0.3

func UIntPtr(i uint) *uint

func UIntPtr32 added in v1.0.3

func UIntPtr32(i uint32) *uint32

func UIntPtr64 added in v1.0.3

func UIntPtr64(i uint64) *uint64

Types

type Bool

type Bool bool

func (Bool) ToBoolPtr added in v1.0.8

func (b Bool) ToBoolPtr() *bool

func (Bool) ToInt

func (b Bool) ToInt() int

ToInt cast bool to represented bool

func (Bool) ToString

func (b Bool) ToString() string

ToString cast bool to represented string

type BoolPtr added in v1.0.3

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

func (*BoolPtr) Scan added in v1.0.6

func (p *BoolPtr) Scan(value interface{}) error

func (BoolPtr) Value added in v1.0.6

func (p BoolPtr) Value() (driver.Value, error)

type Int

type Int int

func (Int) ToBool

func (i Int) ToBool() bool

ToBool cast Int to bool. Returns true for i > 0 & return false for i <= 0

func (Int) ToInt added in v1.0.3

func (i Int) ToInt() int

func (Int) ToInt16 added in v1.0.11

func (i Int) ToInt16() int16

func (Int) ToInt16Ptr added in v1.0.11

func (i Int) ToInt16Ptr() *int16

func (Int) ToInt32 added in v1.0.3

func (i Int) ToInt32() int32

func (Int) ToInt32Ptr added in v1.0.6

func (i Int) ToInt32Ptr() *int32

func (Int) ToInt64 added in v1.0.3

func (i Int) ToInt64() int64

func (Int) ToInt64Ptr added in v1.0.6

func (i Int) ToInt64Ptr() *int64

func (Int) ToIntPtr added in v1.0.3

func (i Int) ToIntPtr() *int

func (Int) ToString

func (i Int) ToString() string

ToString cast Int to string

type Int16Ptr added in v1.0.11

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

func (*Int16Ptr) Scan added in v1.0.11

func (p *Int16Ptr) Scan(value interface{}) error

func (Int16Ptr) Value added in v1.0.11

func (p Int16Ptr) Value() (driver.Value, error)

type Int32Arr added in v1.0.5

type Int32Arr []int32

func (Int32Arr) ToIntArr added in v1.0.5

func (a Int32Arr) ToIntArr() []int

type Int32Ptr added in v1.0.6

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

func (*Int32Ptr) Scan added in v1.0.6

func (p *Int32Ptr) Scan(value interface{}) error

func (Int32Ptr) Value added in v1.0.6

func (p Int32Ptr) Value() (driver.Value, error)

type Int64Arr added in v1.0.5

type Int64Arr []int64

func (Int64Arr) ToIntArr added in v1.0.5

func (a Int64Arr) ToIntArr() []int

type Int64Ptr added in v1.0.6

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

func (*Int64Ptr) Scan added in v1.0.6

func (p *Int64Ptr) Scan(value interface{}) error

func (Int64Ptr) Value added in v1.0.6

func (p Int64Ptr) Value() (driver.Value, error)

type IntArr added in v1.0.5

type IntArr []int

func (IntArr) ToInt32Arr added in v1.0.5

func (a IntArr) ToInt32Arr() []int32

func (IntArr) ToInt32PtrArr added in v1.0.5

func (a IntArr) ToInt32PtrArr() []*int32

func (IntArr) ToInt64Arr added in v1.0.5

func (a IntArr) ToInt64Arr() []int64

func (IntArr) ToInt64PtrArr added in v1.0.5

func (a IntArr) ToInt64PtrArr() []*int64

type IntPtr added in v1.0.3

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

func (*IntPtr) Scan added in v1.0.6

func (p *IntPtr) Scan(value interface{}) error

func (IntPtr) Value added in v1.0.6

func (p IntPtr) Value() (driver.Value, error)

type String

type String string

func (String) MaskLeft

func (s String) MaskLeft(NLeft int, char rune) string

MaskLeft mask string with a char(rune) and left n value on the left side Example: String("MASKED:NOT_MASKED").MaskLeft(11, '*') returns ******:NOT_MASKED

func (String) MaskRight

func (s String) MaskRight(NLeft int, char rune) string

MaskRight mask string with a char(rune) and left n value on the right side Example: String("NOT_MASKED:MASKED").MaskRight(11, '*') returns NOT_MASKED:******

func (String) MustToBool added in v1.0.10

func (s String) MustToBool() bool

MustToBool cast String to bool with panic on error instead

func (String) MustToInt added in v1.0.10

func (s String) MustToInt() int

MustToInt cast String to int with panic on error instead

func (String) ToBool

func (s String) ToBool() (bool, error)

ToBool cast String to represented bool

func (String) ToInt

func (s String) ToInt() (int, error)

ToInt cast String to int

func (String) ToIntArr

func (s String) ToIntArr(separator ...string) ([]int, error)

ToIntArr cast String to array of int

func (String) ToStringArr

func (s String) ToStringArr(separator ...string) ([]string, error)

ToStringArr cast String to array of string

func (String) ToStringPtr added in v1.0.7

func (s String) ToStringPtr() *string

type StringPtr added in v1.0.3

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

func (*StringPtr) Scan added in v1.0.6

func (p *StringPtr) Scan(value interface{}) error

func (StringPtr) Value added in v1.0.6

func (p StringPtr) Value() (driver.Value, error)

type UInt added in v1.0.2

type UInt uint

func (UInt) ToBool added in v1.0.2

func (u UInt) ToBool() (bool, error)

ToBool cast UInt to bool. Returns true for i > 0 & return false for i <= 0

func (UInt) ToString added in v1.0.2

func (u UInt) ToString() (string, error)

ToString cast UInt to string

func (UInt) ToUInt added in v1.0.3

func (u UInt) ToUInt() uint

func (UInt) ToUInt32 added in v1.0.3

func (u UInt) ToUInt32() uint32

func (UInt) ToUInt64 added in v1.0.3

func (u UInt) ToUInt64() uint64

func (UInt) ToUIntPtr added in v1.0.3

func (u UInt) ToUIntPtr() *uint

func (UInt) ToUIntPtr32 added in v1.0.3

func (u UInt) ToUIntPtr32() *uint32

func (UInt) ToUIntPtr64 added in v1.0.3

func (u UInt) ToUIntPtr64() *uint64

Jump to

Keyboard shortcuts

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