bytewriter.go 535 B

12345678910111213141516171819202122232425262728293031323334353637
  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. var newline = []byte{'\n'}
  10. type ByteWriter struct {
  11. io.Writer
  12. c int
  13. }
  14. func (w *ByteWriter) Write(p []byte) (n int, err error) {
  15. if len(p) == 0 {
  16. return
  17. }
  18. for n = range p {
  19. if w.c%12 == 0 {
  20. w.Writer.Write(newline)
  21. w.c = 0
  22. }
  23. fmt.Fprintf(w.Writer, "0x%02x,", p[n])
  24. w.c++
  25. }
  26. n++
  27. return
  28. }