From 475e5a5e9583c80d52a7da5d3bfe3700703d64bc Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 13 Feb 2025 10:56:09 +0800 Subject: [PATCH] {group_,}index: Use name_desc_t --- http_handle_group_index.go | 10 ++-------- http_handle_index.go | 10 ++-------- misc.go | 6 ++++++ diff --git a/http_handle_group_index.go b/http_handle_group_index.go index cd711015e9c884672279a5de2946de1d64d8af17..3098076bdcf2c5cf210f7f6b5a56273d6bba1f6c 100644 --- a/http_handle_group_index.go +++ b/http_handle_group_index.go @@ -14,20 +14,14 @@ return } 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 e36332d701d953efe3a4f3c1cbbc565be27f7306..41a55e81c0933303a945c2367d97ad482c11b34e 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -12,20 +12,14 @@ return } 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 0000000000000000000000000000000000000000..a43f20a4254f3ea658de6473a5caa5f374cf0c27 --- /dev/null +++ b/misc.go @@ -0,0 +1,6 @@ +package main + +type name_desc_t struct { + Name string + Description string +} -- 2.48.1