https://github.com/tcort/luhn
Simple go package that implements the Luhn algorithm
https://github.com/tcort/luhn
checker credit-card luhn luhn-algorithm validation
Last synced: about 1 year ago
JSON representation
Simple go package that implements the Luhn algorithm
- Host: GitHub
- URL: https://github.com/tcort/luhn
- Owner: tcort
- License: isc
- Created: 2016-05-06T02:15:42.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-14T01:10:55.000Z (almost 10 years ago)
- Last Synced: 2025-02-01T05:26:09.438Z (about 1 year ago)
- Topics: checker, credit-card, luhn, luhn-algorithm, validation
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# luhn
Simple [go](https://golang.org/) package that implements the
[Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm).
## Installation
The latest and greatest version of this software is available at
[github.com/tcort/luhn](https://github.com/tcort/luhn).
go get github.com/tcort/luhn
## API
For complete API documentation, see [godoc.org/github.com/tcort/luhn](https://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](https://github.com/tcort/luhn/blob/master/LICENSE.md)