chore(db): remove obsolete text.go, text_test.go and uuid.go

These files were superseded by internal/db/utils.go.
This commit is contained in:
BBQ
2026-02-13 20:42:00 +08:00
parent b3c869f0ff
commit 14a1f9cad3
3 changed files with 0 additions and 67 deletions
-11
View File
@@ -1,11 +0,0 @@
package db
import "github.com/jackc/pgx/v5/pgtype"
// TextToString returns the string value of pgtype.Text, or "" when invalid.
func TextToString(value pgtype.Text) string {
if !value.Valid {
return ""
}
return value.String
}
-26
View File
@@ -1,26 +0,0 @@
package db
import (
"testing"
"github.com/jackc/pgx/v5/pgtype"
)
func TestTextToString(t *testing.T) {
tests := []struct {
name string
value pgtype.Text
want string
}{
{"valid", pgtype.Text{String: "hello", Valid: true}, "hello"},
{"invalid", pgtype.Text{}, ""},
{"valid empty", pgtype.Text{String: "", Valid: true}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := TextToString(tt.value); got != tt.want {
t.Errorf("TextToString() = %q, want %q", got, tt.want)
}
})
}
}
-30
View File
@@ -1,30 +0,0 @@
package db
import (
"fmt"
"strings"
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
// ParseUUID converts a string UUID to pgtype.UUID.
func ParseUUID(id string) (pgtype.UUID, error) {
parsed, err := uuid.Parse(strings.TrimSpace(id))
if err != nil {
return pgtype.UUID{}, fmt.Errorf("invalid UUID: %w", err)
}
var pgID pgtype.UUID
pgID.Valid = true
copy(pgID.Bytes[:], parsed[:])
return pgID, nil
}
// TimeFromPg converts a pgtype.Timestamptz to time.Time.
func TimeFromPg(value pgtype.Timestamptz) time.Time {
if value.Valid {
return value.Time
}
return time.Time{}
}