stringwriter.go 449 B

123456789101112131415161718192021222324252627282930
  1. // This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
  2. // license. Its contents can be found at:
  3. // http://creativecommons.org/publicdomain/zero/1.0/
  4. package bindata
  5. import (
  6. "fmt"
  7. "io"
  8. )
  9. type StringWriter struct {
  10. io.Writer
  11. c int
  12. }
  13. func (w *StringWriter) Write(p []byte) (n int, err error) {
  14. if len(p) == 0 {
  15. return
  16. }
  17. for n = range p {
  18. fmt.Fprintf(w.Writer, "\\x%02x", p[n])
  19. w.c++
  20. }
  21. n++
  22. return
  23. }