Skip to content
/ luhn Public

Simple go package that implements the Luhn algorithm

License

Notifications You must be signed in to change notification settings

tcort/luhn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luhn

Simple go package that implements the Luhn algorithm.

Installation

The latest and greatest version of this software is available at github.com/tcort/luhn.

go get github.com/tcort/luhn

API

For complete API documentation, see godoc.org/github.com/tcort/luhn

Example Usage

Here's a simple command line tool that accepts a number as a command line argument and reports whether or not it passed the Luhn check:

package main

import (
    "fmt"
    "github.com/tcort/luhn"
    "os"
)

func main() {

    if len(os.Args) != 2 {
        fmt.Println("Usage: lc [number]")
        return
    }

    if luhn.Check(os.Args[1]) {
        fmt.Println("The number passed the Luhn check")
    } else {
        fmt.Println("The number failed the Luhn check")
    }
}

License

See LICENSE.md

About

Simple go package that implements the Luhn algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages