repo.or.cz
/
debiancodesearch.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
show: make highlight legible
[debiancodesearch.git]
/
shardmapping
/
shardmapping.go
blob
4cb74afbe7d33728ac4c385dd5ecd3bea62cadfa
1
package
shardmapping
2
3
import
(
4
"crypto/md5"
5
"fmt"
6
"io"
7
"log"
8
"strconv"
9
)
10
11
func
TaskIdxForPackage
(
pkg
string
,
tasks
int
)
int
{
12
h
:=
md5
.
New
()
13
io
.
WriteString
(
h
,
pkg
)
14
i
,
err
:=
strconv
.
ParseInt
(
fmt
.
Sprintf
(
"
%x
"
,
h
.
Sum
(
nil
)[:
6
]),
16
,
64
)
15
if
err
!=
nil
{
16
log
.
Fatal
(
err
)
17
}
18
return
int
(
i
) %
tasks
19
}