str := base64.StdEncoding.EncodeToString([]byte(`foo bar`)) fmt.Println(str) // Output: Zm9vIGJhcg==
Playground