refactor: clean code
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
// 出参:
|
||||
// - certPEM: 证书 PEM 内容。
|
||||
// - err: 错误。
|
||||
func ConvertCertificateToPEM(cert *x509.Certificate) (certPEM string, err error) {
|
||||
func ConvertCertificateToPEM(cert *x509.Certificate) (_certPEM string, _err error) {
|
||||
if cert == nil {
|
||||
return "", errors.New("`cert` is nil")
|
||||
}
|
||||
@@ -37,14 +37,14 @@ func ConvertCertificateToPEM(cert *x509.Certificate) (certPEM string, err error)
|
||||
// 出参:
|
||||
// - privkeyPEM: 私钥 PEM 内容。
|
||||
// - err: 错误。
|
||||
func ConvertECPrivateKeyToPEM(privkey *ecdsa.PrivateKey) (privkeyPEM string, err error) {
|
||||
func ConvertECPrivateKeyToPEM(privkey *ecdsa.PrivateKey) (_privkeyPEM string, _err error) {
|
||||
if privkey == nil {
|
||||
return "", errors.New("`privkey` is nil")
|
||||
}
|
||||
|
||||
data, err := x509.MarshalECPrivateKey(privkey)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to marshal EC private key: %w", err)
|
||||
data, _err := x509.MarshalECPrivateKey(privkey)
|
||||
if _err != nil {
|
||||
return "", fmt.Errorf("failed to marshal EC private key: %w", _err)
|
||||
}
|
||||
|
||||
block := &pem.Block{
|
||||
|
||||
Reference in New Issue
Block a user