join.go 429 B

123456789101112131415161718192021
  1. package astutils
  2. import (
  3. "strings"
  4. "github.com/kyleconroy/sqlc/internal/sql/ast"
  5. "github.com/kyleconroy/sqlc/internal/sql/ast/pg"
  6. )
  7. func Join(list *ast.List, sep string) string {
  8. items := []string{}
  9. for _, item := range list.Items {
  10. if n, ok := item.(*ast.String); ok {
  11. items = append(items, n.Str)
  12. }
  13. if n, ok := item.(*pg.String); ok {
  14. items = append(items, n.Str)
  15. }
  16. }
  17. return strings.Join(items, sep)
  18. }