util.go 413 B

12345678910111213141516171819202122232425
  1. package plist
  2. import "io"
  3. type countedWriter struct {
  4. io.Writer
  5. nbytes int
  6. }
  7. func (w *countedWriter) Write(p []byte) (int, error) {
  8. n, err := w.Writer.Write(p)
  9. w.nbytes += n
  10. return n, err
  11. }
  12. func (w *countedWriter) BytesWritten() int {
  13. return w.nbytes
  14. }
  15. func unsignedGetBase(s string) (string, int) {
  16. if len(s) > 1 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') {
  17. return s[2:], 16
  18. }
  19. return s, 10
  20. }