Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/base64: add examples #4136

Closed
gopherbot opened this issue Sep 23, 2012 · 7 comments
Closed

encoding/base64: add examples #4136

gopherbot opened this issue Sep 23, 2012 · 7 comments
Milestone

Comments

@gopherbot
Copy link

by joaopintojeronimo:

In http://golang.org/pkg/encoding/base64/, it's very hard to figure out how to do an
encoding and decoding, I tried two methods and had to go to the IRC channel so they
could help me out, and they suggested that I should open this issue.
@minux
Copy link
Member

minux commented Sep 23, 2012

Comment 1:

do you want to contribute examples for encoding/base64?
examples are (almost) always welcome.

Labels changed: added priority-later, go1.1, removed priority-triage.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 2 by joaopintojeronimo:

I would love to contribute but I didn't understand very well how to use that package. I
think two very important examples would be encoding and decoding a string, since people
who come from other programming languages are very to that. The simple encoding of a
string would be:
// Encoding
data := "a string to be encoded"
enc := base64.StdEncoding
encLength := enc.EncodedLen(len(data))
dst := make([]byte, encLength)
enc.Encode(dst, []byte(uniqueID))
encodedData := string(dst)
And I still don't know how to decode it (to be fair, have not tried it, if I have the
time I'll look at the docs again and post it here)

@fsouza
Copy link
Contributor

fsouza commented Sep 24, 2012

Comment 3:

Here is an example: http://play.golang.org/p/Expz7K_Ehw

@wvh
Copy link

wvh commented Sep 25, 2012

Comment 4:

That example annoyingly leaves a trailing 0x0 that needs to be stripped. Maybe this is
not so easy after all. :)

@wvh
Copy link

wvh commented Sep 25, 2012

Comment 5:

That example annoyingly leaves a trailing 0x0 that needs to be stripped. Maybe this is
not so easy after all. :)
Try this:
http://play.golang.org/p/jZnlfoqyhC

@dsymonds
Copy link
Contributor

dsymonds commented Oct 8, 2012

Comment 6:

Owner changed to @dsymonds.

@dsymonds
Copy link
Contributor

dsymonds commented Oct 8, 2012

Comment 7:

This issue was closed by revision 05e4e80.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants