types.go 501 B

12345678910111213141516
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package jsonutil
  4. // Bytes is a byte slice in a json-encoded struct.
  5. // encoding/json assumes that []byte fields are hex-encoded.
  6. // Bytes are not hex-encoded; they are treated the same as strings.
  7. // This can avoid unnecessary allocations due to a round trip through strings.
  8. type Bytes []byte
  9. func (b *Bytes) UnmarshalText(text []byte) error {
  10. // Copy the contexts of text.
  11. *b = append(*b, text...)
  12. return nil
  13. }