code: func savePrivateKey(key crypto.PrivateKey) ([]byte, error) {
  	var pemType string
  	var keyBytes []byte
  	switch key := key.(type) {
  	case *ecdsa.PrivateKey:
  		var err error
  		pemType = "EC"
  		keyBytes, err = x509.MarshalECPrivateKey(key)
  		if err != nil {
  			return nil, err
  		}
  	case *rsa.PrivateKey:
  		pemType = "RSA"
  		keyBytes = x509.MarshalPKCS1PrivateKey(key)
  	}
  
  	pemKey := pem.Block{Type: pemType + " PRIVATE KEY", Bytes: keyBytes}
  	return pem.EncodeToMemory(&pemKey), nil
  }
docs: // savePrivateKey saves a PEM-encoded ECC/RSA private key to an array of bytes.