encoding.go 439 B

123456789101112131415
  1. package missinggo
  2. // An interface for "encoding/base64".Encoder
  3. type Encoding interface {
  4. EncodeToString([]byte) string
  5. DecodeString(string) ([]byte, error)
  6. }
  7. // An encoding that does nothing.
  8. type IdentityEncoding struct{}
  9. var _ Encoding = IdentityEncoding{}
  10. func (IdentityEncoding) EncodeToString(b []byte) string { return string(b) }
  11. func (IdentityEncoding) DecodeString(s string) ([]byte, error) { return []byte(s), nil }