utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Character Format (Fixed or variable blocked)
	CharacterFileFormat = "character"
	// Packed Format (Variable blocked)
	PackedFileFormat = "packed"
	// Name of header record
	HeaderRecordName = "header"
	// Name of trailer record
	TrailerRecordName = "trailer"
	// Name of data record
	DataRecordName = "data"

	// Json format
	MessageJsonFormat = "json"
	// Metro format
	MessageMetroFormat = "metro"
)

Variables

View Source
var (
	// ErrInvalidMetroFile is given when there's an invalid file
	ErrInvalidMetroFile = errors.New("the file isn't metro file")
	// ErrNonHeaderRecord is given when there isn't header record
	ErrNonHeaderRecord = errors.New("the file must have header record")
)

Functions

func IsMetroFile

func IsMetroFile(buf []byte) bool

Metro file check

func IsPacked added in v0.3.2

func IsPacked(buf []byte) bool

IsPacked packed format check

func IsVariableLength

func IsVariableLength(data []byte) bool

Variable block check

func NewErrApplicableSegment

func NewErrApplicableSegment(recordName, segName string) error

NewErrApplicableSegment returns a error that can't support applicable segment

func NewErrBlockDescriptorWord

func NewErrBlockDescriptorWord() error

NewErrBlockDescriptorWord returns a error that

func NewErrFailedParsing added in v0.3.0

func NewErrFailedParsing() error

NewErrFailedParsing returns a error that is failed parsing raw data

func NewErrFieldRequired added in v0.3.0

func NewErrFieldRequired(fieldName, recordName string) error

NewErrFieldRequired is given when a field is required

func NewErrInvalidRecord added in v0.3.0

func NewErrInvalidRecord(name string) error

NewErrInvalidRecord returns a error if is invalid record

func NewErrInvalidSegment added in v0.3.0

func NewErrInvalidSegment(name string) error

NewErrInvalidSegment returns a error that has invalid segment

func NewErrInvalidValueOfField added in v0.3.0

func NewErrInvalidValueOfField(fieldName, recordName string) error

NewErrInvalidValueOfField returns a error that has invalid value

func NewErrNonAlphanumeric added in v0.3.0

func NewErrNonAlphanumeric(fieldName, recordName string) error

NewErrNonAlphanumeric is given when a field has non-alphanumeric characters

func NewErrNumeric added in v0.3.0

func NewErrNumeric(fieldName, recordName string) error

NewErrNumeric is given when a field is not numeric characters

func NewErrPhoneNumber added in v0.3.0

func NewErrPhoneNumber(recordName string) error

NewErrPhoneNumber is given when a field is an invalid phone number

func NewErrSegmentLength added in v0.3.0

func NewErrSegmentLength(recordName string) error

NewErrSegmentLength is given when a segment has an invalid length

func NewErrUpperAlpha added in v0.3.0

func NewErrUpperAlpha(fieldName, recordName string) error

NewErrUpperAlpha is given when a field is not in uppercase

func NewErrValidDate added in v0.3.0

func NewErrValidDate(fieldName, recordName string) error

NewErrValidDate is given when there's an invalid date

func ReadFile

func ReadFile(f *os.File) []byte

File Read

Types

type Time added in v0.4.0

type Time time.Time

func (*Time) IsZero added in v0.5.0

func (ct *Time) IsZero() bool

IsZero reports whether t represents the zero time instant,

func (Time) MarshalJSON added in v0.4.0

func (ct Time) MarshalJSON() ([]byte, error)

MarshalJSON writes a quoted string in the custom format

func (*Time) String added in v0.4.0

func (ct *Time) String() string

String returns the time in the custom format

func (*Time) UnmarshalJSON added in v0.4.0

func (ct *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON Parses the json string in the custom format

Jump to

Keyboard shortcuts

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