aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-13 10:56:09 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-13 10:56:09 +0800
commit475e5a5e9583c80d52a7da5d3bfe3700703d64bc (patch)
tree7ea95a3fcc11f369a45555b50df2ab72680bda04
parentgroup_index: Use table list (diff)
downloadforge-475e5a5e9583c80d52a7da5d3bfe3700703d64bc.tar.gz
forge-475e5a5e9583c80d52a7da5d3bfe3700703d64bc.tar.zst
forge-475e5a5e9583c80d52a7da5d3bfe3700703d64bc.zip
{group_,}index: Use name_desc_t
-rw-r--r--http_handle_group_index.go10
-rw-r--r--http_handle_index.go10
-rw-r--r--misc.go6
3 files changed, 10 insertions, 16 deletions
diff --git a/http_handle_group_index.go b/http_handle_group_index.go
index cd71101..3098076 100644
--- a/http_handle_group_index.go
+++ b/http_handle_group_index.go
@@ -14,20 +14,14 @@ func handle_group_repos(w http.ResponseWriter, r *http.Request, params map[strin
}
defer rows.Close()
- repos := []struct {
- Name string
- Description string
- }{}
+ repos := []name_desc_t{}
for rows.Next() {
var repoName, repoDescription string
if err := rows.Scan(&repoName, &repoDescription); err != nil {
http.Error(w, "Error scanning repo: "+err.Error(), http.StatusInternalServerError)
return
}
- repos = append(repos, struct {
- Name string
- Description string
- }{repoName, repoDescription})
+ repos = append(repos, name_desc_t{repoName, repoDescription})
}
params["repos"] = repos
diff --git a/http_handle_index.go b/http_handle_index.go
index e36332d..41a55e8 100644
--- a/http_handle_index.go
+++ b/http_handle_index.go
@@ -12,20 +12,14 @@ func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any)
}
defer rows.Close()
- groups := []struct {
- Name string
- Description string
- }{}
+ groups := []name_desc_t{}
for rows.Next() {
var groupName, groupDescription string
if err := rows.Scan(&groupName, &groupDescription); err != nil {
http.Error(w, "Error scanning group: "+err.Error(), http.StatusInternalServerError)
return
}
- groups = append(groups, struct {
- Name string
- Description string
- }{groupName, groupDescription})
+ groups = append(groups, name_desc_t{groupName, groupDescription})
}
if err := rows.Err(); err != nil {
diff --git a/misc.go b/misc.go
new file mode 100644
index 0000000..a43f20a
--- /dev/null
+++ b/misc.go
@@ -0,0 +1,6 @@
+package main
+
+type name_desc_t struct {
+ Name string
+ Description string
+}