use arguments for ids

main
Zynh0722 2024-02-25 13:36:20 -08:00
parent 0682104dc8
commit 92e4d5ed2a
1 changed files with 28 additions and 16 deletions

14
main.go
View File

@ -7,6 +7,7 @@ import (
"log" "log"
"os" "os"
"path" "path"
"strconv"
"time" "time"
"github.com/karashiiro/bingode" "github.com/karashiiro/bingode"
@ -41,9 +42,19 @@ func main() {
log.Fatalln(err) 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 // bingle: 29932586
// dialus: 44540671 // dialus: 44540671
var id uint32 = 44540671
data, ok := cache[id] data, ok := cache[id]
if !ok || time.Now().After(data.Time.Add(time.Minute*10)) { if !ok || time.Now().After(data.Time.Add(time.Minute*10)) {
cache[id] = refetch_data(id) cache[id] = refetch_data(id)
@ -61,6 +72,7 @@ func main() {
} }
fmt.Printf("%s\n", data.Data) fmt.Printf("%s\n", data.Data)
} }
}
func refetch_data(id uint32) CacheRecord { func refetch_data(id uint32) CacheRecord {
log.New(os.Stderr, "", 0).Printf("Fetching fresh data for %d\n", id) log.New(os.Stderr, "", 0).Printf("Fetching fresh data for %d\n", id)