From a6d7a1e868ed5a155049f83bc688d0f97dacb323 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 05 Apr 2025 21:54:45 +0800 Subject: [PATCH] Unexport some other things --- config.go | 3 --- database.go | 10 +++++----- http_handle_group_index.go | 9 +++++---- http_handle_index.go | 4 ++-- diff --git a/config.go b/config.go index 35484783b76fa65703b22da42faa042210df90c4..5abbfb06dcfa816a385922160df35e97eb0eb79a 100644 --- a/config.go +++ b/config.go @@ -13,9 +13,6 @@ "codeberg.org/emersion/go-scfg" "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 edfadbf28f7972c6bd77db31ad77488d42463d9f..b1aca72768eca9f6e29f508645cc5d21e5ca002c 100644 --- a/database.go +++ b/database.go @@ -15,10 +15,10 @@ // to exceptions if appropriate) so they get a consistent view of the database // 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 @@ var name, description string 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 bb9c94f0fe67c8318da88427957ef21934a06e3e..a607ba26e57666a85b8ebcbc1a175131d765c59c 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 package forge @@ -19,8 +20,8 @@ // of its subgroups and repos, as well as a form for group maintainers to // 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 @@ if err = rows.Scan(&name, &description); err != nil { 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 @@ if err = rows.Scan(&name, &description); err != nil { 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 fd89a86332bc3d3ddcfd52fa3f1fb72e1eb223e6..a519a5a7099e1de29de74181e508261e498b8497 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -14,9 +14,9 @@ // httpHandleIndex provides the main index page which includes a list of groups // 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 -- 2.48.1