go get github.com/fanchann/nik-parser
example:
nik_parser.go
package main
import (
"encoding/json"
"fmt"
nikparser "github.com/fanchann/nik-parser"
)
func main() {
nik := "3203012503770011"
result, err := nikparser.ParseNIK(nik)
if err != nil {
fmt.Printf("%v \n", err)
return
}
jsonByte, _ := json.Marshal(result)
fmt.Println(string(jsonByte))
}
nik_gen.go
package main
import (
"fmt"
nikparser "github.com/fanchann/nik-parser"
)
func main() {
nikOpts := &nikparser.NIKOpts{District: "Your District", PostalCode: "PostCode",Ttl: 20}
niks := nikparser.NIKGen(nikOpts)
fmt.Printf("niks: %v\n", niks)
jsonByte, _ := json.Marshal(&niks)
ioutil.WriteFile("nik.json", jsonByte, fs.ModePerm)
}