Standard library / crypto/aes
crypto/aes.KeySizeError.Error()
Reports the invalid key length in bytes. Use errors.As to classify constructor failures rather than parsing the text. Expected stdout: 'true 0\ntrue\n'.
Formal Syntax & Structure
go syntaxgo
func (k KeySizeError) Error() stringReturn Value
string
Diagnostic describing the rejected size.
Working Example
Example Snippetgo
package main
import ( "crypto/aes" "errors" "fmt")
func main() { _, err := aes.NewCipher(nil) var k aes.KeySizeError fmt.Println(errors.As(err, &k), int(k)) fmt.Println(k.Error() != "")}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}