parser

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 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/dimasbagussusilo/nb-go-parser
  1. Import it in your code
import "github.com/dimasbagussusilo/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

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

func GetOptBoolArg

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

func GetOptInt32Arg

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

func GetOptInt64Arg

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

func GetOptIntArg

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

func GetOptStringArg

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

func UIntPtr

func UIntPtr(i uint) *uint

func UIntPtr32

func UIntPtr32(i uint32) *uint32

func UIntPtr64

func UIntPtr64(i uint64) *uint64

Types

type Bool

type Bool bool

func (Bool) ToBoolPtr

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

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

func (*BoolPtr) Scan

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

func (BoolPtr) Value

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

func (i Int) ToInt() int

func (Int) ToInt16

func (i Int) ToInt16() int16

func (Int) ToInt16Ptr

func (i Int) ToInt16Ptr() *int16

func (Int) ToInt32

func (i Int) ToInt32() int32

func (Int) ToInt32Ptr

func (i Int) ToInt32Ptr() *int32

func (Int) ToInt64

func (i Int) ToInt64() int64

func (Int) ToInt64Ptr

func (i Int) ToInt64Ptr() *int64

func (Int) ToIntPtr

func (i Int) ToIntPtr() *int

func (Int) ToString

func (i Int) ToString() string

ToString cast Int to string

type Int16Ptr

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

func (*Int16Ptr) Scan

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

func (Int16Ptr) Value

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

type Int32Arr

type Int32Arr []int32

func (Int32Arr) ToIntArr

func (a Int32Arr) ToIntArr() []int

type Int32Ptr

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

func (*Int32Ptr) Scan

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

func (Int32Ptr) Value

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

type Int64Arr

type Int64Arr []int64

func (Int64Arr) ToIntArr

func (a Int64Arr) ToIntArr() []int

type Int64Ptr

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

func (*Int64Ptr) Scan

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

func (Int64Ptr) Value

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

type IntArr

type IntArr []int

func (IntArr) ToInt32Arr

func (a IntArr) ToInt32Arr() []int32

func (IntArr) ToInt32PtrArr

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

func (IntArr) ToInt64Arr

func (a IntArr) ToInt64Arr() []int64

func (IntArr) ToInt64PtrArr

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

type IntPtr

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

func (*IntPtr) Scan

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

func (IntPtr) Value

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

func (s String) MustToBool() bool

MustToBool cast String to bool with panic on error instead

func (String) MustToInt

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

func (s String) ToStringPtr() *string

type StringPtr

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

func (*StringPtr) Scan

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

func (StringPtr) Value

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

type UInt

type UInt uint

func (UInt) ToBool

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

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

func (UInt) ToString

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

ToString cast UInt to string

func (UInt) ToUInt

func (u UInt) ToUInt() uint

func (UInt) ToUInt32

func (u UInt) ToUInt32() uint32

func (UInt) ToUInt64

func (u UInt) ToUInt64() uint64

func (UInt) ToUIntPtr

func (u UInt) ToUIntPtr() *uint

func (UInt) ToUIntPtr32

func (u UInt) ToUIntPtr32() *uint32

func (UInt) ToUIntPtr64

func (u UInt) ToUIntPtr64() *uint64

Jump to

Keyboard shortcuts

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