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 (
    "encoding/base64"
)
  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:
fmt.Println(encoded)

Let me know if you have any further questions.