luhn

package module
v0.0.0-...-3dc418f Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 0 Imported by: 0

README

Luhn Algorithm

Generating check number & validating Luhn numbers in GO

Usage

import "https://github.com/vasilenkodm/luhn"

func main() {
	// Checking if a string is a valid luhn
	luhn.Valid(1111) //= false
	luhn.Valid(79927398713) //= true

  luhn.CalculateLuhn(7992739871) //= 3
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateLuhn

func CalculateLuhn[T Number](number T) T

CalculateLuhn return the check number

func Valid

func Valid[T Number](number T) bool

Valid check number is valid or not based on Luhn algorithm

Types

type Number

type Number interface {
	~int | ~uint | ~int64 | ~uint64
}

Jump to

Keyboard shortcuts

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