From 252921635a661a0231ca713565fa37b0faacd793 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Tue, 11 Feb 2025 11:15:42 +0800 Subject: [PATCH] *.go: Reformat --- handle_repo_tree.go | 8 ++++---- template_funcs.go | 2 +- diff --git a/handle_repo_tree.go b/handle_repo_tree.go index 4c3eaa1928596ec6fd583daf6a22d3f5d6ccd316..7a996921b3cc50dfba7f21014cacec522b86291b 100644 --- a/handle_repo_tree.go +++ b/handle_repo_tree.go @@ -4,8 +4,8 @@ import ( "bytes" "html/template" "net/http" - "strings" "path" + "strings" chroma_formatters_html "github.com/alecthomas/chroma/v2/formatters/html" chroma_lexers "github.com/alecthomas/chroma/v2/lexers" @@ -77,7 +77,7 @@ return } formatted_encapsulated := template.HTML(formatted_unencapsulated.Bytes()) data["file_contents"] = formatted_encapsulated - + err = templates.ExecuteTemplate(w, "repo_tree_file", data) if err != nil { _, _ = w.Write([]byte("Error rendering template: " + err.Error())) @@ -87,8 +87,8 @@ return } } - if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec) - 1] != '/' { - http.Redirect(w, r, path.Base(path_spec) + "/", http.StatusSeeOther) + if len(raw_path_spec) != 0 && raw_path_spec[len(raw_path_spec)-1] != '/' { + http.Redirect(w, r, path.Base(path_spec)+"/", http.StatusSeeOther) return } diff --git a/template_funcs.go b/template_funcs.go index 08932baeff3163785681dd717e617d8432b2c920..19a92ecd1218f1f1ecaf3fa2df32315108651b98 100644 --- a/template_funcs.go +++ b/template_funcs.go @@ -10,6 +10,6 @@ before, _, _ := strings.Cut(s, "\n") return before } -func base_name (s string) string { +func base_name(s string) string { return path.Base(s) } -- 2.48.1