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/binary: missing documentation for BigEndian and LittleEndian functions #68083

Open
nilskch opened this issue Jun 20, 2024 · 7 comments
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.

Comments

@nilskch
Copy link

nilskch commented Jun 20, 2024

Go version

go version go1.22.3 darwin/arm64

Output of go env in your module/workspace:

It is not important here and contains information about my employer that I do not want to share.

What did you do?

I wanted to use the functions of the littleEndian and bigEndian types and noticed that gopls does not provide a function documentation. I was unsure about the exact behavior and needed to look up the implementation.

What did you see happen?

gopls just provides the function definition with description (see here).

What did you expect to see?

I wanted to see a documentation of those functions. Would you accept a PR that adds the documentation?

@gabyhelp
Copy link

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@seankhliao seankhliao changed the title encoding/binary: missing godoc documentation for BigEndian and LittleEndian functions encoding/binary: missing documentation for BigEndian and LittleEndian functions Jun 21, 2024
@seankhliao
Copy link
Member

Given the function names are quite self-explanatory, what other information would the function docs contain?

@nilskch
Copy link
Author

nilskch commented Jun 21, 2024

For example, PutUint16([]byte, uint16) accepts byte slices of any length. Where will the 2 bytes be stored? At the beginning or the end of the slice? This behavior is not intuitive to me just from the function definition.

@dr2chase
Copy link
Contributor

I checked that adding the documentation would work (the bug referenced by gabyhelp made me wonder) so I think a pull request would be fine. There may be some back-and-forth on the exact wording in review, but if it tripped you up, it is probably a problem for other people, and is worth fixing.

There's a process, if this is too much, say so (that's also useful feedback) and maybe someone else will write the docs and you can comment on whether that meets your needs.

@joedian joedian added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 25, 2024
@rsc
Copy link
Contributor

rsc commented Jun 28, 2024

They have documentation. https://pkg.go.dev/encoding/binary#pkg-variables
It sounds like you are saying gopls does not show the documentation?

@nilskch
Copy link
Author

nilskch commented Jun 28, 2024

@rsc the variables LittleEndian, BigEndian and NativeEndian have documentation. The interfaces ByteOrder and AppendByteOrder have documentation as well, but the functions of the structs littleEndian and bigEndian that implement those interfaces don't (littleEndian, bigEndian).

When you hover over binary.LittleEndian.PutUint16 gopls only returns the function definition func (littleEndian) PutUint16(b []byte, v uint16) without any further documentation and therefore I needed to lookup the implementation.

@nilskch
Copy link
Author

nilskch commented Jun 28, 2024

There may be some back-and-forth on the exact wording in review, but if it tripped you up, it is probably a problem for other people, and is worth fixing.

@dr2chase I will look into it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants