Here is how a private key can be converted to Ethereum address
You need to import one additional package "crypto/ecdsa" and also remove "0x" from the private key.
privateKey, err := crypto.HexToECDSA(privateKey2)
if err != nil {
log.Fatal(err)
}
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
log.Fatal("error casting public key to ECDSA")
}
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…