//LEAPI - ACME Certificate Renewal Control API - Copyright 2022-2025 Ruel Tmeizeh All Rights Reserved package main import ( "fmt" "io/ioutil" "log" "os" "regexp" "strings" "time" "github.com/google/uuid" ) func readJsonFile(filePath string) (jsonBytes []byte, err error) { jsonFile, err := os.Open(filePath) if err != nil { log.Println("Could not open JSON file: " + filePath + "\n" + err.Error()) return jsonBytes, err } defer jsonFile.Close() fileBytes, _ := ioutil.ReadAll(jsonFile) //strip out // comments from file: re := regexp.MustCompile(`([\s]//.*)|(^//.*)`) fileCleanedBytes := re.ReplaceAll(fileBytes, nil) return fileCleanedBytes, err } func generateUUID() string { return strings.Replace(uuid.New().String(), "-", "", -1) } func fileExists(filename string) bool { info, err := os.Stat(filename) if os.IsNotExist(err) { return false } return !info.IsDir() } func uptime() UpOut { uptime := fmt.Sprintf("%s", time.Since(startupTime)) out := UpOut{ Up: true, StartTime: startupTime, Uptime: uptime, } return out }