title: GO - How to convert public key from string to PEM format
body: <p>I am trying to use jwt library to do jwt validation. And i am getting public key from another application by calling its REST endpoint which is returning public key in string format. </p>
  
  <p>So now when trying to send that public key in same string format, i am getting "Invalid key format". Any help on how to convert string formatted key to a valid PEM format would be great. </p>
  
  <pre><code>func (test *TESTStrategy) doJWTValidation(token string, key string, logger *util.Logger) (TESTResponse, error) {
      parsedToken, jwtErr := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) {
          return decodedJWT.ParsedPubKey, nil
      })
  </code></pre>
  
  <p>Below is the error what i am getting when passing key as a string to jwt.Pasrse() call. </p>
  
  <p><a href="https://i.stack.imgur.com/tmxwc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tmxwc.png" alt="enter image description here"></a></p>
  
  <p>Public Key:
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsFWkb/eSl6I3DRVhaonW3DFy8EnL0yaPiDzCcOLuYfBjN9zZIR1wXmnMJFle1K89qHGg42wgweVTIwA1XFTfoUKSziwsjF6FscZX5H56ZYyS/wWiO3rWWynlfbSZt+ga71+ndsu+A0Dy7Nn7ZgP8kRsu4UM5vE7QQTRERNiUKpzScN1cgZUFUqSddQmkwTEN8hH1mFX1Mum54NGqWIlmQxQDrOyogmMXIaaakhabcmuIPMULVVDVwUJC9sSDsc/j05qcZn3kkiEBRyiYB6ZLY2W7WfiV+dB7/icPONsYSD0FxHWEGNnbqtiGoNf9WZWtaP+o8WMR9sB3GKGVnbLvbQIDAQAB</p>