use Duration for doorOpenTime + lint
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
2023-08-17 20:14:38 +03:00
parent e0dacb1e4b
commit 8c14e3bc41
2 changed files with 37 additions and 28 deletions

View File

@@ -217,7 +217,7 @@ func (doobserver *DoorBoyServer) postKeepDoorOpen(w http.ResponseWriter, r *http
rs, _ := io.ReadAll(r.Body)
parsedTime, err := time.Parse(time.RFC3339, strings.TrimSpace(string(rs)))
if err != nil {
fmt.Println("Error with parsing time: %v", err)
fmt.Printf("Error with parsing time: %v", err)
w.WriteHeader(http.StatusBadRequest)
}
keepOpenUntil = &parsedTime
@@ -229,6 +229,9 @@ func main() {
var dumpKeys []cardToken
savedKeys, err := os.ReadFile("keys.json")
if err != nil {
log.Fatalf("reading saved keys from keys.json: %v", err)
}
err = json.Unmarshal(savedKeys, &dumpKeys)
if err == nil {
@@ -268,7 +271,7 @@ func main() {
keyLock.Lock()
data, err := json.Marshal(keys)
if err == nil {
os.WriteFile("keys.json", data, 0600)
os.WriteFile("keys.json", data, 0o600)
log.Println("Saved keys successfully!")
}
keyLock.Unlock()