use arguments for ids

This commit is contained in:
Zynh0722 2024-02-25 13:36:20 -08:00
parent 0682104dc8
commit 92e4d5ed2a

14
main.go
View file

@ -7,6 +7,7 @@ import (
"log"
"os"
"path"
"strconv"
"time"
"github.com/karashiiro/bingode"
@ -41,9 +42,19 @@ func main() {
log.Fatalln(err)
}
args := os.Args[1:]
for _, arg := range args {
id_64, err := strconv.ParseUint(arg, 10, 32)
if err != nil {
log.New(os.Stderr, "", 0).Println(err)
os.Exit(2)
}
id := uint32(id_64)
// bingle: 29932586
// dialus: 44540671
var id uint32 = 44540671
data, ok := cache[id]
if !ok || time.Now().After(data.Time.Add(time.Minute*10)) {
cache[id] = refetch_data(id)
@ -60,6 +71,7 @@ func main() {
log.Fatalln(err)
}
fmt.Printf("%s\n", data.Data)
}
}
func refetch_data(id uint32) CacheRecord {