mirror of
https://github.com/golang/go.git
synced 2025-05-22 16:09:37 +00:00
encoding/hex: improve Decode and DecodeString docs
Simplify the wording of both. Make the DecodeString docs more accurate: DecodeString returns a slice, not a string. Change-Id: Iba7003f55fb0a37aafcbeee59a30492c0f68aa4e Reviewed-on: https://go-review.googlesource.com/115615 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e4259d67b9
commit
a34e6650c0
@ -50,8 +50,8 @@ func DecodedLen(x int) int { return x / 2 }
|
||||
// Decode decodes src into DecodedLen(len(src)) bytes,
|
||||
// returning the actual number of bytes written to dst.
|
||||
//
|
||||
// Decode expects that src contain only hexadecimal
|
||||
// characters and that src should have an even length.
|
||||
// Decode expects that src contains only hexadecimal
|
||||
// characters and that src has even length.
|
||||
// If the input is malformed, Decode returns the number
|
||||
// of bytes decoded before the error.
|
||||
func Decode(dst, src []byte) (int, error) {
|
||||
@ -101,10 +101,10 @@ func EncodeToString(src []byte) string {
|
||||
|
||||
// DecodeString returns the bytes represented by the hexadecimal string s.
|
||||
//
|
||||
// DecodeString expects that src contain only hexadecimal
|
||||
// characters and that src should have an even length.
|
||||
// If the input is malformed, DecodeString returns a string
|
||||
// containing the bytes decoded before the error.
|
||||
// DecodeString expects that src contains only hexadecimal
|
||||
// characters and that src has even length.
|
||||
// If the input is malformed, DecodeString returns
|
||||
// the bytes decoded before the error.
|
||||
func DecodeString(s string) ([]byte, error) {
|
||||
src := []byte(s)
|
||||
// We can use the source slice itself as the destination
|
||||
|
Loading…
x
Reference in New Issue
Block a user