Browse Source

Initial commit

José González Krause 1 year ago
commit
de5e5f65b7
4 changed files with 155 additions and 0 deletions
  1. 57 0
      .gitignore
  2. 72 0
      LICENSE
  3. 3 0
      README.md
  4. 23 0
      dnigen.go

+ 57 - 0
.gitignore

@@ -0,0 +1,57 @@
+# ---> Go
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
+*.prof
+
+# ---> macOS
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+# ---> VisualStudioCode
+.settings
+
+

File diff suppressed because it is too large
+ 72 - 0
LICENSE


+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# dnigen
+
+Simple CLI tool for generating Spanish ID number letter.

+ 23 - 0
dnigen.go

@@ -0,0 +1,23 @@
+package main
+
+import (
+	"flag"
+	"fmt"
+	"strings"
+)
+
+const alph = "TRWAGMYFPDXBNJZSQVHLCKE"
+
+func main() {
+	dniFlag := flag.Int("dni", 0, "The Spanish DNI/NIF number")
+	flag.Parse()
+
+	if *dniFlag == 0 {
+		flag.PrintDefaults()
+		return
+	}
+
+	alphArr := strings.SplitAfterN(alph, "", -1)
+
+	fmt.Printf("%d-%s\n", *dniFlag, alphArr[*dniFlag%23])
+}