tangled
alpha
login
or
join now
cuducos.me
/
go-cpf
0
fork
atom
🇧🇷 CPF validation in Go
0
fork
atom
overview
issues
pulls
pipelines
Better "set" functionality
Thanks @danielfireman
Eduardo Cuducos
6 years ago
4fcfdb79
41a024a5
+8
-5
1 changed file
expand all
collapse all
unified
split
cpf.go
+8
-5
cpf.go
···
7
7
"strings"
8
8
)
9
9
10
10
+
//auxiliar type and variable to build a set
11
11
+
type void struct{}
12
12
+
13
13
+
var member void
14
14
+
10
15
//Cpf type
11
16
type Cpf string
12
17
···
34
39
return false
35
40
}
36
41
37
37
-
var (
38
38
-
ds = make([]int64, 11)
39
39
-
m = map[int64]bool{}
40
40
-
)
42
42
+
ds := make([]int64, 11)
43
43
+
s := make(map[int64]void)
41
44
for i, v := range strings.Split(u, "") {
42
45
c, err := strconv.ParseInt(v, 10, 32)
43
46
if err != nil {
44
47
return false
45
48
}
46
49
ds[i] = c
47
47
-
m[c] = true
50
50
+
s[c] = member
48
51
}
49
52
50
53
if len(m) == 1 {