diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 21:54:45 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 21:54:45 +0800 |
commit | a6d7a1e868ed5a155049f83bc688d0f97dacb323 (patch) | |
tree | df3eafec8f6f896a9ae0312519ee97e0a46f0a78 | |
parent | Do not export version (diff) | |
download | forge-a6d7a1e868ed5a155049f83bc688d0f97dacb323.tar.gz forge-a6d7a1e868ed5a155049f83bc688d0f97dacb323.tar.zst forge-a6d7a1e868ed5a155049f83bc688d0f97dacb323.zip |
Unexport some other things
-rw-r--r-- | config.go | 3 | ||||
-rw-r--r-- | database.go | 10 | ||||
-rw-r--r-- | http_handle_group_index.go | 9 | ||||
-rw-r--r-- | http_handle_index.go | 4 |
4 files changed, 12 insertions, 14 deletions
@@ -13,9 +13,6 @@ import ( "github.com/jackc/pgx/v5/pgxpool" ) -// config holds the global configuration used by this instance. There is -// currently no synchronization mechanism, so it must not be modified after -// request handlers are spawned. type Config struct { HTTP struct { Net string `scfg:"net"` diff --git a/database.go b/database.go index edfadbf..b1aca72 100644 --- a/database.go +++ b/database.go @@ -15,10 +15,10 @@ import ( // at a single point. A failure to do so may cause things as serious as // privilege escalation. -// QueryNameDesc is a helper function that executes a query and returns a +// queryNameDesc is a helper function that executes a query and returns a // list of nameDesc results. The query must return two string arguments, i.e. a // name and a description. -func (s *Server) QueryNameDesc(ctx context.Context, query string, args ...any) (result []NameDesc, err error) { +func (s *Server) queryNameDesc(ctx context.Context, query string, args ...any) (result []nameDesc, err error) { var rows pgx.Rows if rows, err = s.database.Query(ctx, query, args...); err != nil { @@ -31,13 +31,13 @@ func (s *Server) QueryNameDesc(ctx context.Context, query string, args ...any) ( if err = rows.Scan(&name, &description); err != nil { return nil, err } - result = append(result, NameDesc{name, description}) + result = append(result, nameDesc{name, description}) } return result, rows.Err() } -// NameDesc holds a name and a description. -type NameDesc struct { +// nameDesc holds a name and a description. +type nameDesc struct { Name string Description string } diff --git a/http_handle_group_index.go b/http_handle_group_index.go index bb9c94f..a607ba2 100644 --- a/http_handle_group_index.go +++ b/http_handle_group_index.go @@ -1,4 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-only + // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> package forge @@ -19,8 +20,8 @@ import ( // create repos. func (s *Server) httpHandleGroupIndex(writer http.ResponseWriter, request *http.Request, params map[string]any) { var groupPath []string - var repos []NameDesc - var subgroups []NameDesc + var repos []nameDesc + var subgroups []nameDesc var err error var groupID int var groupDesc string @@ -154,7 +155,7 @@ func (s *Server) httpHandleGroupIndex(writer http.ResponseWriter, request *http. errorPage500(writer, params, "Error getting repos: "+err.Error()) return } - repos = append(repos, NameDesc{name, description}) + repos = append(repos, nameDesc{name, description}) } if err = rows.Err(); err != nil { errorPage500(writer, params, "Error getting repos: "+err.Error()) @@ -179,7 +180,7 @@ func (s *Server) httpHandleGroupIndex(writer http.ResponseWriter, request *http. errorPage500(writer, params, "Error getting subgroups: "+err.Error()) return } - subgroups = append(subgroups, NameDesc{name, description}) + subgroups = append(subgroups, nameDesc{name, description}) } if err = rows.Err(); err != nil { errorPage500(writer, params, "Error getting subgroups: "+err.Error()) diff --git a/http_handle_index.go b/http_handle_index.go index fd89a86..a519a5a 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -14,9 +14,9 @@ import ( // and some global information such as SSH keys. func (s *Server) httpHandleIndex(writer http.ResponseWriter, request *http.Request, params map[string]any) { var err error - var groups []NameDesc + var groups []nameDesc - groups, err = s.QueryNameDesc(request.Context(), "SELECT name, COALESCE(description, '') FROM groups WHERE parent_group IS NULL") + groups, err = s.queryNameDesc(request.Context(), "SELECT name, COALESCE(description, '') FROM groups WHERE parent_group IS NULL") if err != nil { errorPage500(writer, params, "Error querying groups: "+err.Error()) return |