code: func PublicKeyToDER(publicKey interface{}) ([]byte, error) {
  	if publicKey == nil {
  		return nil, errors.New("Invalid public key. It must be different from nil.")
  	}
  
  	switch k := publicKey.(type) {
  	case *ecdsa.PublicKey:
  		if k == nil {
  			return nil, errors.New("Invalid ecdsa public key. It must be different from nil.")
  		}
  		PubASN1, err := x509.MarshalPKIXPublicKey(k)
  		if err != nil {
  			return nil, err
  		}
  
  		return PubASN1, nil
  
  	case *rsa.PublicKey:
  		if k == nil {
  			return nil, errors.New("Invalid rsa public key. It must be different from nil.")
  		}
  		PubASN1, err := x509.MarshalPKIXPublicKey(k)
  		if err != nil {
  			return nil, err
  		}
  
  		return PubASN1, nil
  
  	default:
  		return nil, errors.New("Invalid key type. It must be *ecdsa.PublicKey or *rsa.PublicKey")
  	}
  }
docs: // PublicKeyToDER marshals a public key to the der format