aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 21:23:00 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 21:23:00 +0800
commited069956471b57d408ecfe2b415eb9dcf08e6c53 (patch)
tree4050675d0940ca76c50dd551628520e74da6cb0d
parentUse cmd/forge for the entry point (diff)
downloadforge-ed069956471b57d408ecfe2b415eb9dcf08e6c53.tar.gz
forge-ed069956471b57d408ecfe2b415eb9dcf08e6c53.tar.zst
forge-ed069956471b57d408ecfe2b415eb9dcf08e6c53.zip
Export symbols from database.go
-rw-r--r--database.go10
-rw-r--r--http_handle_group_index.go8
-rw-r--r--http_handle_index.go4
3 files changed, 11 insertions, 11 deletions
diff --git a/database.go b/database.go
index eafad33..a627f2d 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 cc33860..e0e460d 100644
--- a/http_handle_group_index.go
+++ b/http_handle_group_index.go
@@ -19,8 +19,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 +154,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 +179,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 a519a5a..fd89a86 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