Help us shape the future of Go! Take the 2026 Go Developer Survey

iso6346

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: MIT Imports: 3 Imported by: 0

README

An implementation of iso6346 check-digit algorithm

Go Report Card Coverage Status Build Status

Algorithm will detect wrong container numbers.

It is not intended to be a cryptographically secure hash function. It is mostly used for preflight container numbers.

Compatible with the ozzo-validation package.

Usage

import "github.com/kolkov/iso6346"

err := iso6346.Validate("CMAU5110875")

signed := iso6346.Generate("CMAU511087")

test on your own by running make benchmark

Resources

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValueNotIso6346 = errors.New("iso6346: must be valid number by iso6346 algorithm")
View Source
var ErrValueNotLen10 = errors.New("iso6346: must be 10 char")
View Source
var ErrValueNotLen11 = errors.New("iso6346: must be 11 char length")

Functions

func CalcCheckDigit

func CalcCheckDigit(code string) (int, error)

CalcCheckDigit calculates check digit for iso6346 algorithm.

func Generate

func Generate(source string) (string, error)

Generate return the number with check digit

func Validate

func Validate(value interface{}) error

Validate check number is valid or not based on iso6346 algorithm

Types

This section is empty.

Jump to

Keyboard shortcuts

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