code: func ParsePrivateKeyPEM(keyData []byte) (interface{}, error) {
  	var privateKeyPemBlock *pem.Block
  	for {
  		privateKeyPemBlock, keyData = pem.Decode(keyData)
  		if privateKeyPemBlock == nil {
  			break
  		}
  
  		switch privateKeyPemBlock.Type {
  		case ECPrivateKeyBlockType:
  			// ECDSA Private Key in ASN.1 format
  			if key, err := x509.ParseECPrivateKey(privateKeyPemBlock.Bytes); err == nil {
  				return key, nil
  			}
  		case RSAPrivateKeyBlockType:
  			// RSA Private Key in PKCS#1 format
  			if key, err := x509.ParsePKCS1PrivateKey(privateKeyPemBlock.Bytes); err == nil {
  				return key, nil
  			}
  		case PrivateKeyBlockType:
  			// RSA or ECDSA Private Key in unencrypted PKCS#8 format
  			if key, err := x509.ParsePKCS8PrivateKey(privateKeyPemBlock.Bytes); err == nil {
  				return key, nil
  			}
  		}
  
  		// tolerate non-key PEM blocks for compatibility with things like "EC PARAMETERS" blocks
  		// originally, only the first PEM block was parsed and expected to be a key block
  	}
  
  	// we read all the PEM blocks and didn't recognize one
  	return nil, fmt.Errorf("data does not contain a valid RSA or ECDSA private key")
  }
docs: // ParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data.
  // Recognizes PEM blocks for "EC PRIVATE KEY", "RSA PRIVATE KEY", or "PRIVATE KEY"