pkg/system: move memory-info types to pkg/systeminfo, and minor refactor#44663
pkg/system: move memory-info types to pkg/systeminfo, and minor refactor#44663thaJeztah merged 4 commits intomoby:masterfrom
Conversation
|
Failure in Jenkins; looks like the latest test-changes did not yet fix all things 😂 |
Use a single exported implementation, so that we can maintain the GoDoc string in one place, and use non-exported functions for the actual implementation (which were already in place). Signed-off-by: Sebastiaan van Stijn <[email protected]>
These types and functions are more closely related to the functionality provided by pkg/systeminfo, and used in conjunction with the other functions in that package, so moving them there. Signed-off-by: Sebastiaan van Stijn <[email protected]>
It was only used in a test, and only for a single const; define it locally. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use a single exported implementation, so that we can maintain the GoDoc string in one place, and use non-exported functions for the actual implementation. Signed-off-by: Sebastiaan van Stijn <[email protected]>
fb89834 to
ec878a3
Compare
corhere
left a comment
There was a problem hiding this comment.
I spy another minor refactor opportunity: replace the popcnt function in pkg/sysinfo/numcpu_windows.go with https://pkg.go.dev/math/bits#OnesCount64
| @@ -0,0 +1,24 @@ | |||
| package sysinfo | |||
There was a problem hiding this comment.
| package sysinfo | |
| package sysinfo // import "github.com/docker/docker/pkg/sysinfo" |
There was a problem hiding this comment.
Ah, probably should've mentioned that; so these import comments act at the package level; so technically, only a single file in the package needs to have it to enforce the import.
As we're planning to move to go modules (and thus rename the module), I'm preemptively removing these comments in files I move to other packages (if there's already at least one of those comments in the package) to reduce further code-churn a bit.
Overall the import comments are starting to lose value, as in many cases (if go mod is involved in any way), they're completely ignored.
Ah, nice find; yes, can look at that. |
|
Thx! Let me bring this one in 👍 |
pkg/sysinfo: unify NumCPU implementation
Use a single exported implementation, so that we can maintain the
GoDoc string in one place, and use non-exported functions for the
actual implementation (which were already in place).
pkg/system: move memory-info types to pkg/systeminfo
These types and functions are more closely related to the functionality
provided by pkg/systeminfo, and used in conjunction with the other functions
in that package, so moving them there.
pkg/sysinfo: remove github.com/docker/go-units dependency
It was only used in a test, and only for a single const; define
it locally.
pkg/sysinfo: unify ReadMemInfo implementation
Use a single exported implementation, so that we can maintain the
GoDoc string in one place, and use non-exported functions for the
actual implementation.