Closed zeddee closed 5 years ago
@zeddee ah thanks for the clarification and correcting the misinformation. The change looks good
hey @miguelmota , i've updated the PR to correct the "casting/type assertion" error messages across the guide:
from:
log.Fatal("error casting public key to ECDSA")
to:
log.Fatal("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
@zeddee merged. thanks for the PR 👍
Go doesn't "cast" types — would be more accurate to describe this as a type assertion, to correctly reflect what is going on with the Go code.
Not casting because
priv.Public()
returns an interface, which has an underlying type of*ecdsa.PublicKey
. CallingpublicKey.(*ecdsa.PublicKey)
doesn't perform a conversion, but instead asserts*ecdsa.PublicKey
as the resulting variable's type. If*ecdsa.PublicKey
is not the underlying type of the variable it is performed on, the operation panics. The underlying type of the variable the type assertion is called on never changes.If change is ok, will make changes across the rest of the guide.
source: https://stackoverflow.com/a/19579058