Skip to content
September 13, 2011 / Rohit

Base 64 Encoding in Go

The Go language documentation doesn’t have enough examples. Here is one way to do it:

package main
import (
    "fmt"
    "encoding/base64"
)

func main() {
        str := "Hello world"
        encodedStr := base64.StdEncoding.EncodeToString([]byte(str))
        fmt.Printf(encodedStr)
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: