server/repochecker/update.go

33 lines
561 B
Go
Raw Normal View History

2021-11-13 15:30:45 +00:00
//go:build checkupdate
// +build checkupdate
package main
import (
"encoding/json"
"io"
"log"
"net/http"
)
2022-05-10 08:23:28 +00:00
const version = 12
func init() {
go checkUpdate()
}
func checkUpdate() {
2023-05-16 08:00:15 +00:00
res, err := http.Get("https://fic.srs.epita.fr/repochecker.version")
if err == nil {
defer res.Body.Close()
dec := json.NewDecoder(res.Body)
var v int
if err := dec.Decode(&v); err == io.EOF || err == nil {
if v > version {
2023-05-16 08:00:15 +00:00
log.Println("Your repochecker version is outdated, please update it:\n https://fic.srs.epita.fr/fic-binaries/")
}
}
}
}