base64 encode golang

To encode a string to base64 in Go, you can use the encoding/base64 package. Here are the steps to perform base64 encoding in Go:

  1. Import the encoding/base64 package:
import (
  1. Convert the string to a byte slice:
str := "Hello, World!"
byteSlice := []byte(str)
  1. Encode the byte slice to base64:
encoded := base64.StdEncoding.EncodeToString(byteSlice)
  1. Print the encoded string:

Let me know if you have any further questions.