Files
Gogs/internal/dbutil/string.go
ᴊᴏᴇ ᴄʜᴇɴ 59e9fa191b chore: remove all MIT license file headers (#8083)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2026-01-08 19:32:15 -05:00

22 lines
441 B
Go

package dbutil
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...)
}