Files
Gogs/internal/dbx/string.go
ᴊᴏᴇ ᴄʜᴇɴ 36d56d5525 all: rename packages ending with "util" to end with "x" (#8182)
Co-authored-by: JSS <jss@unknwon.dev>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:25:19 -05:00

22 lines
438 B
Go

package dbx
import (
"fmt"
"gogs.io/gogs/internal/conf"
)
// Quote adds surrounding double quotes for all given arguments before being
// formatted if the current database is UsePostgreSQL.
func Quote(format string, args ...string) string {
anys := make([]any, len(args))
for i := range args {
if conf.UsePostgreSQL {
anys[i] = `"` + args[i] + `"`
} else {
anys[i] = args[i]
}
}
return fmt.Sprintf(format, anys...)
}