Bytes converts the given string representation of a byte sequence into a slice of bytes A bytes sequence is encoded in URL-safe base64 without padding
(val string)
| 179 | // Bytes converts the given string representation of a byte sequence into a slice of bytes |
| 180 | // A bytes sequence is encoded in URL-safe base64 without padding |
| 181 | func Bytes(val string) ([]byte, error) { |
| 182 | b, err := base64.StdEncoding.DecodeString(val) |
| 183 | if err != nil { |
| 184 | b, err = base64.URLEncoding.DecodeString(val) |
| 185 | if err != nil { |
| 186 | return nil, err |
| 187 | } |
| 188 | } |
| 189 | return b, nil |
| 190 | } |
| 191 | |
| 192 | // BytesSlice converts 'val' where individual bytes sequences, encoded in URL-safe |
| 193 | // base64 without padding, are separated by 'sep' into a slice of byte slices. |
no outgoing calls
no test coverage detected