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/pem: Decode documentation misleading #53524

Open
eikenb opened this issue Jun 24, 2022 · 2 comments
Open

encoding/pem: Decode documentation misleading #53524

eikenb opened this issue Jun 24, 2022 · 2 comments
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@eikenb
Copy link

eikenb commented Jun 24, 2022

What is the URL of the page with the issue?

https://pkg.go.dev/encoding/pem

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

Screenshot

Screenshot_from_2022-06-23_18-32-30

What did you do?

Used pem.Decode() as described.

What did you expect to see?

To have it "Decode will find the next PEM formatted block (certificate, private key etc) in the input. It returns that block and the remainder of the input."

What did you see instead?

It only found PEM formatted blocks when preceded by a newline, with no characters on the line before the "-----BEGIN" nor on the line after the end's "-----". It wasn't clear until I read the code that it was line by line with these restrictions. The docs made it sound like it looked for the PEM blocks using bytes.Index(bytestream, "-----BEGIN") and like (what I ended up using locally).

IMO the documentation is misleading here and should be fixed.

Thanks!

@eikenb eikenb added the pkgsite label Jun 24, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jun 24, 2022
@eikenb eikenb changed the title x/pkgsite: x/pkgsite: pem.Decode() documentation misleading Jun 24, 2022
@ianlancetaylor ianlancetaylor changed the title x/pkgsite: pem.Decode() documentation misleading encoding/pem: Decode documentation misleading Jun 24, 2022
@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Documentation pkgsite labels Jun 24, 2022
@ianlancetaylor
Copy link
Contributor

CC @FiloSottile

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/421636 mentions this issue: encoding/pem: clarify Decode only works on lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants