dnigen.go 342 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "strings"
  6. )
  7. const alph = "TRWAGMYFPDXBNJZSQVHLCKE"
  8. func main() {
  9. dniFlag := flag.Int("dni", 0, "The Spanish DNI/NIF number")
  10. flag.Parse()
  11. if *dniFlag == 0 {
  12. flag.PrintDefaults()
  13. return
  14. }
  15. alphArr := strings.SplitAfterN(alph, "", -1)
  16. fmt.Printf("%d-%s\n", *dniFlag, alphArr[*dniFlag%23])
  17. }