cont

package
v0.0.0-...-a579f6b Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcCheckDigit

func CalcCheckDigit(ownerCode string, equipCatID rune, serialNum int) int

CalcCheckDigit calculates check digit for owner, equipment category ID and serial number.

func IsEquipCatID

func IsEquipCatID(ID string) error

IsEquipCatID checks if string is one upper case letter.

func IsHeightWidthCode

func IsHeightWidthCode(code string) error

IsHeightWidthCode returns nil if input is one upper case alphanumeric character.

func IsLengthCode

func IsLengthCode(code string) error

IsLengthCode returns nil if input is one upper case alphanumeric character.

func IsOwnerCode

func IsOwnerCode(code string) error

IsOwnerCode checks if string is three upper case letters.

func IsTypeCode

func IsTypeCode(code string) error

IsTypeCode returns nil if input is two upper case alphanumeric characters.

func NewValidateError

func NewValidateError(message string) error

NewValidateError returns a new ValidateError.

Types

type EquipCat

type EquipCat struct {
	Value string
	Info  string
}

EquipCat has an ID and additional information for the ID.

func NewEquipCatID

func NewEquipCatID(id string, info string) EquipCat

NewEquipCatID creates a new equipment category with an ID and an information.

type EquipCatID

type EquipCatID struct {
	Value string
}

EquipCatID is the equipment category ID in a container number.

type GeneratorBuilder

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

GeneratorBuilder is the struct for the builder. Use NewUniqueGeneratorBuilder to create a new one.

func NewUniqueGeneratorBuilder

func NewUniqueGeneratorBuilder(rand *rand.Rand) *GeneratorBuilder

NewUniqueGeneratorBuilder returns a new random unique container number generator. If possible maximum unique container numbers are exceeded, count is less than 1 or no owner codes are passed then nil and error is returned.

func (*GeneratorBuilder) Build

func (gb *GeneratorBuilder) Build() (*UniqueGenerator, error)

Build returns a new UniqueGenerator if all requirements are met.

func (*GeneratorBuilder) Count

func (gb *GeneratorBuilder) Count(count int) *GeneratorBuilder

Count sets the count of container number.

func (*GeneratorBuilder) End

func (gb *GeneratorBuilder) End(end int) *GeneratorBuilder

End sets the end of serial number range.

func (*GeneratorBuilder) ExcludeCheckDigit10

func (gb *GeneratorBuilder) ExcludeCheckDigit10(exclude bool) *GeneratorBuilder

ExcludeCheckDigit10 sets the exclusion of container numbers with check digit 10.

func (*GeneratorBuilder) ExcludeErrorProneSerialNumbers

func (gb *GeneratorBuilder) ExcludeErrorProneSerialNumbers(exclude bool) *GeneratorBuilder

ExcludeErrorProneSerialNumbers sets the exclusion of container numbers with error-prone serial numbers.

func (*GeneratorBuilder) OwnerCodes

func (gb *GeneratorBuilder) OwnerCodes(codes []string) *GeneratorBuilder

OwnerCodes sets the owner codes for generation.

func (*GeneratorBuilder) Start

func (gb *GeneratorBuilder) Start(start int) *GeneratorBuilder

Start sets the start of serial number range.

type GroupInfo

type GroupInfo string

GroupInfo has information about the specified type group.

type Height

type Height string

Height describes height of first code in the specified standard size code.

type Length

type Length string

Length describes length of second code in the specified standard size code.

type Number

type Number struct {
	OwnerCode    string
	EquipCatID   rune
	SerialNumber int
	CheckDigit   int
}

Number is a container number with needed properties to conform to the specified standard.

type Owner

type Owner struct {
	Code    string
	Company string
	City    string
	Country string
}

Owner has a code and associated company with its location in the form of country and city.

type TpNumber

type TpNumber struct {
	Number
	// Pos is the position of the two transposed numbers starting with 0.
	// For example Pos 1 means that the second and third digits are transposed.
	Pos int
}

func CheckTransposition

func CheckTransposition(ownerCode string, equipCatID rune, serialNum int, checkDigit int) []TpNumber

CheckTransposition returns an array of TpNumber's for error-prone serial numbers. CheckTransposition returns nil if no error-prone serial number is found. Not equal adjacent digits including check digit are transposed and checked.

type TypeInfo

type TypeInfo string

TypeInfo has information about the specified standard type.

type UniqueGenerator

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

UniqueGenerator holds state for generating random unique container numbers. Use NewUniqueGeneratorBuilder for initialization.

func (*UniqueGenerator) ContNum

func (g *UniqueGenerator) ContNum() Number

ContNum returns a generated container number.

func (*UniqueGenerator) Generate

func (g *UniqueGenerator) Generate() bool

Generate advances the serial number iterator to the next serial number, which will then be available through the ContNum method. It returns false when the generation stops by reaching the count of generated container numbers.

type ValidateError

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

ValidateError is an error for validation of a container number part.

func (*ValidateError) Error

func (e *ValidateError) Error() string

type Width

type Width string

Width describes width of first code in the specified standard size code.

Jump to

Keyboard shortcuts

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