common.go 408 B

1234567891011121314151617181920212223242526
  1. package postgres
  2. import (
  3. "fmt"
  4. "strings"
  5. "google.golang.org/protobuf/encoding/protojson"
  6. )
  7. var (
  8. protojsonUnmarshaler = protojson.UnmarshalOptions{
  9. DiscardUnknown: true,
  10. }
  11. )
  12. func placeholder(n int) string {
  13. return "$" + fmt.Sprint(n)
  14. }
  15. func placeholders(n int) string {
  16. list := []string{}
  17. for i := 0; i < n; i++ {
  18. list = append(list, placeholder(i+1))
  19. }
  20. return strings.Join(list, ", ")
  21. }