// Base64 implements flag.Value, and is used to populate []byte values from baes64 encoded strings.
typeBase64struct{
val[]byte
lenint
}
// NewBase64 returns a Base64 which accepts values which decode to len byte strings.
funcNewBase64(lenint)*Base64{
return&Base64{
len:len,
}
}
func(f*Base64)String()string{
returnbase64.StdEncoding.EncodeToString(f.val)
}
// Set will set the []byte value of the Base64 to the base64 decoded values of the string, returning an error if it cannot be decoded or is of the wrong length.
// If no value has been set, a nil []byte is returned.
func(f*Base64)Bytes()[]byte{
returnf.val
}
// NewBase64List returns a Base64List which accepts a comma-separated list of strings which must decode to len byte strings.
funcNewBase64List(lenint)*Base64List{
return&Base64List{
len:len,
}
}
// Base64List implements flag.Value and is used to populate [][]byte values from a comma-separated list of base64 encoded strings.
typeBase64Liststruct{
val[][]byte
lenint
}
// Set will set the [][]byte value of the Base64List to the base64 decoded values of the comma-separated strings, returning an error on the first error it encounters.