本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
803B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package builder
  5. import (
  6. "io"
  7. "strings"
  8. )
  9. // Writer defines the interface
  10. type Writer interface {
  11. io.Writer
  12. Append(...interface{})
  13. }
  14. var _ Writer = NewWriter()
  15. // BytesWriter implments Writer and save SQL in bytes.Buffer
  16. type BytesWriter struct {
  17. *strings.Builder
  18. args []interface{}
  19. }
  20. // NewWriter creates a new string writer
  21. func NewWriter() *BytesWriter {
  22. w := &BytesWriter{
  23. Builder: &strings.Builder{},
  24. }
  25. return w
  26. }
  27. // Append appends args to Writer
  28. func (w *BytesWriter) Append(args ...interface{}) {
  29. w.args = append(w.args, args...)
  30. }
  31. // Args returns args
  32. func (w *BytesWriter) Args() []interface{} {
  33. return w.args
  34. }
上海开阖软件有限公司 沪ICP备12045867号-1