1
0

string.go 441 B

123456789101112131415161718192021
  1. package dbutil
  2. import (
  3. "fmt"
  4. "gogs.io/gogs/internal/conf"
  5. )
  6. // Quote adds surrounding double quotes for all given arguments before being
  7. // formatted if the current database is UsePostgreSQL.
  8. func Quote(format string, args ...string) string {
  9. anys := make([]any, len(args))
  10. for i := range args {
  11. if conf.UsePostgreSQL {
  12. anys[i] = `"` + args[i] + `"`
  13. } else {
  14. anys[i] = args[i]
  15. }
  16. }
  17. return fmt.Sprintf(format, anys...)
  18. }