1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 00:18:31 +00:00

flag.Arg(0) not flag.Arg(1) you dummy

This commit is contained in:
Kane York 2015-12-23 23:54:03 -08:00
parent daeb9d1a06
commit b22efabfed

View file

@ -8,7 +8,6 @@ import (
"net/http"
"encoding/gob"
"os"
"github.com/satori/go.uuid"
)
var SERVERS = []string{
@ -31,6 +30,8 @@ Filename should be in one of the following formats:
monthly-12-2015.gob
`
var forceWrite = flag.Bool("f", false, "force servers to write out their current")
func main() {
flag.Parse()
if flag.NArg() < 1 {
@ -38,9 +39,12 @@ func main() {
os.Exit(2)
return
}
gob.RegisterName("hyperloglog", hyperloglog.HyperLogLogPlus{})
filename := flag.Arg(1)
if *forceWrite {
ForceWrite()
}
filename := flag.Arg(0)
hll, err := DownloadAll(filename)
if err != nil {
fmt.Println(err)
@ -51,6 +55,17 @@ func main() {
fmt.Println(hll.Count())
}
func ForceWrite() {
for _, server := range SERVERS {
resp, err := http.Get(fmt.Sprintf("%s/hll_force_write", server))
if err != nil {
fmt.Println(err)
os.Exit(1)
}
resp.Body.Close()
}
}
func DownloadAll(filename string) (*hyperloglog.HyperLogLogPlus, error) {
result, _ := hyperloglog.NewPlus(server.CounterPrecision)