diff --git a/internal/policies/chromium/generator.go b/internal/policies/chromium/generator.go index dd15f48..62a9905 100644 --- a/internal/policies/chromium/generator.go +++ b/internal/policies/chromium/generator.go @@ -14,7 +14,7 @@ import ( var policiesJson string func Generate(policies types.BrowserPolicyContent) (string, error) { - policiesTmpl := map[string]interface{}{} + policiesTmpl := map[string]any{} if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil { return "", err } @@ -23,7 +23,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) { // Extensions // - ExtensionInstallForcelist := []interface{}{} + ExtensionInstallForcelist := []any{} for _, e := range policies.Extensions { URL := e.URL if URL == "" { @@ -36,7 +36,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) { ) } - ExtensionInstallAllowlist := []interface{}{} + ExtensionInstallAllowlist := []any{} for _, e := range policies.Extensions { ExtensionInstallAllowlist = append( ExtensionInstallAllowlist, @@ -46,7 +46,7 @@ func Generate(policies types.BrowserPolicyContent) (string, error) { policiesTmpl["ExtensionInstallForcelist"] = ExtensionInstallForcelist policiesTmpl["ExtensionInstallAllowlist"] = ExtensionInstallAllowlist - policiesTmpl["ExtensionInstallBlocklist"] = []interface{}{"*"} + policiesTmpl["ExtensionInstallBlocklist"] = []any{"*"} // // Developer Tools diff --git a/internal/policies/chromium/parser.go b/internal/policies/chromium/parser.go index 2a2e5a9..bd88ad3 100644 --- a/internal/policies/chromium/parser.go +++ b/internal/policies/chromium/parser.go @@ -12,7 +12,7 @@ import ( func Parse(policiesJson string) (*types.BrowserPolicyContent, error) { policies := types.BrowserPolicyContent{} - policiesTmpl := map[string]interface{}{} + policiesTmpl := map[string]any{} if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil { return nil, err } @@ -23,7 +23,7 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) { if extensions, ok := policiesTmpl["ExtensionInstallForcelist"]; ok { policies.Extensions = []types.BrowserPolicyExtension{} - for _, val := range extensions.([]interface{}) { + for _, val := range extensions.([]any) { s := strings.Split(val.(string), ";") url := "" if len(s) > 1 { diff --git a/internal/policies/firefox/generator.go b/internal/policies/firefox/generator.go index 02bed06..55f6f45 100644 --- a/internal/policies/firefox/generator.go +++ b/internal/policies/firefox/generator.go @@ -14,7 +14,7 @@ var policiesJson string func Generate(policies types.BrowserPolicyContent) (string, error) { policiesTmpl := struct { - Policies map[string]interface{} `json:"policies"` + Policies map[string]any `json:"policies"` }{} if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil { return "", err @@ -24,13 +24,13 @@ func Generate(policies types.BrowserPolicyContent) (string, error) { // Extensions // - ExtensionSettings := map[string]interface{}{} - ExtensionSettings["*"] = map[string]interface{}{ + ExtensionSettings := map[string]any{} + ExtensionSettings["*"] = map[string]any{ "installation_mode": "blocked", } for _, e := range policies.Extensions { - ExtensionSettings[e.ID] = map[string]interface{}{ + ExtensionSettings[e.ID] = map[string]any{ "install_url": e.URL, "installation_mode": "force_installed", } @@ -48,18 +48,18 @@ func Generate(policies types.BrowserPolicyContent) (string, error) { // Persistent Data // - Preferences := policiesTmpl.Policies["Preferences"].(map[string]interface{}) + Preferences := policiesTmpl.Policies["Preferences"].(map[string]any) Preferences["browser.urlbar.suggest.history"] = policies.PersistentData Preferences["places.history.enabled"] = policies.PersistentData policiesTmpl.Policies["Preferences"] = Preferences policiesTmpl.Policies["SanitizeOnShutdown"] = !policies.PersistentData if policies.PersistentData { - policiesTmpl.Policies["Homepage"] = map[string]interface{}{ + policiesTmpl.Policies["Homepage"] = map[string]any{ "StartPage": "previous-session", } } else { - policiesTmpl.Policies["Homepage"] = map[string]interface{}{ + policiesTmpl.Policies["Homepage"] = map[string]any{ "StartPage": "homepage", } } diff --git a/internal/policies/firefox/parser.go b/internal/policies/firefox/parser.go index a950764..26b8eee 100644 --- a/internal/policies/firefox/parser.go +++ b/internal/policies/firefox/parser.go @@ -13,7 +13,7 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) { policies := types.BrowserPolicyContent{} policiesTmpl := struct { - Policies map[string]interface{} `json:"policies"` + Policies map[string]any `json:"policies"` }{} if err := json.Unmarshal([]byte(policiesJson), &policiesTmpl); err != nil { return nil, err @@ -30,12 +30,12 @@ func Parse(policiesJson string) (*types.BrowserPolicyContent, error) { if extensions, ok := policiesTmpl.Policies["ExtensionSettings"]; ok { policies.Extensions = []types.BrowserPolicyExtension{} - for id, val := range extensions.(map[string]interface{}) { + for id, val := range extensions.(map[string]any) { if id == "*" { continue } - data := val.(map[string]interface{}) + data := val.(map[string]any) url, _ := data["install_url"].(string) policies.Extensions = append( diff --git a/internal/server/logger.go b/internal/server/logger.go index 426f0eb..f0a22f8 100644 --- a/internal/server/logger.go +++ b/internal/server/logger.go @@ -14,7 +14,7 @@ type logformatter struct { } func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry { - req := map[string]interface{}{} + req := map[string]any{} if reqID := middleware.GetReqID(r.Context()); reqID != "" { req["id"] = reqID @@ -32,7 +32,7 @@ func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry { req["agent"] = r.UserAgent() req["uri"] = fmt.Sprintf("%s://%s%s", scheme, r.Host, r.RequestURI) - fields := map[string]interface{}{} + fields := map[string]any{} fields["req"] = req return &logentry{ @@ -43,12 +43,12 @@ func (l *logformatter) NewLogEntry(r *http.Request) middleware.LogEntry { type logentry struct { logger zerolog.Logger - fields map[string]interface{} - errors []map[string]interface{} + fields map[string]any + errors []map[string]any } -func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) { - res := map[string]interface{}{} +func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra any) { + res := map[string]any{} res["time"] = time.Now().UTC().Format(time.RFC1123) res["status"] = status res["bytes"] = bytes @@ -65,8 +65,8 @@ func (e *logentry) Write(status, bytes int, header http.Header, elapsed time.Dur } } -func (e *logentry) Panic(v interface{}, stack []byte) { - err := map[string]interface{}{} +func (e *logentry) Panic(v any, stack []byte) { + err := map[string]any{} err["message"] = fmt.Sprintf("%+v", v) err["stack"] = string(stack) diff --git a/internal/utils/color.go b/internal/utils/color.go index 919887c..09f0981 100644 --- a/internal/utils/color.go +++ b/internal/utils/color.go @@ -29,6 +29,6 @@ func Color(str string) string { return result + str[lastIndex:] } -func Colorf(format string, a ...interface{}) string { +func Colorf(format string, a ...any) string { return fmt.Sprintf(Color(format), a...) } diff --git a/internal/utils/swal2.go b/internal/utils/swal2.go index 2bd9d09..7f05db8 100644 --- a/internal/utils/swal2.go +++ b/internal/utils/swal2.go @@ -17,7 +17,7 @@ func Swal2Response(w http.ResponseWriter, body string) { http.Error(w, err.Error(), 500) } - err = tmpl.Execute(w, map[string]interface{}{ + err = tmpl.Execute(w, map[string]any{ "Body": template.HTML(body), })