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

x/sys/cpu: should HWCap and HWCap2 be exported? #30255

Closed
mundaym opened this issue Feb 15, 2019 · 4 comments
Closed

x/sys/cpu: should HWCap and HWCap2 be exported? #30255

mundaym opened this issue Feb 15, 2019 · 4 comments

Comments

@mundaym
Copy link
Member

mundaym commented Feb 15, 2019

Are cpu.HWCap and cpu.HWCap2 supposed to be exported as part of the cpu API? I can't see any discussion about this in CL 150718 where they were added. Presumably they should be properly documented if they are supposed to be exposed.

They are only exposed on non-x86 Linux machines so I expect we could just un-export them if they aren't supposed to be exported...

@gopherbot gopherbot added this to the Unreleased milestone Feb 15, 2019
@tklauser
Copy link
Member

I suspect these were exported because the implementation was based on internal/cpu from the standard library where they need to be exported to be used in runtime.

IMO it would be fine to unexport them, also given the following comment:

// These are initialized in cpu_$GOARCH.go
// and should not be changed after they are initialized.

https://github.com/golang/sys/blob/d0b11bdaac8adb652bff00e49bcacf992835621a/cpu/cpu_linux.go#L23-L24

/cc @ianlancetaylor @bradfitz

@ianlancetaylor
Copy link
Contributor

I agree.

@martisch
Copy link
Contributor

martisch commented Feb 15, 2019

I also agree to make them unexported. They are an implementation detail that should not have be exposed and it is hard to impossible to know from the outside if the value is valid/initialized.

@gopherbot
Copy link

Change https://golang.org/cl/163004 mentions this issue: cpu: unexport HWCap and HWCap2

@golang golang locked and limited conversation to collaborators Feb 19, 2020
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

5 participants