Comments (10)
I agree that it seems better to remove the top level constructor functions and just always require fs
to make the API more consistent. So once the current set of PRs are merged, I'll create another PR to:
- remove the top level
NewThing()
constructor functions - change the FS methods from
NewThing()
toThing()
- since FS would now be required in most/all cases, maybe add a new
FS
constructor such asNewDefaultFS()
for when/proc
and/sys
are in the default locations.
from procfs.
I'd also like to suggest that we get rid of constructor functions like NewBuddyInfo
in favor of methods like: FS.BuddyInfo
, because:
- it will shrink the API surface
- it will reduce redundancy
- it will enable much easier testing
from procfs.
@mdlayher You mean all package level shorthand methods? Even Self()
?
from procfs.
Good question. I suppose it depends how much some of them are used. While they may be convenient, I imagine that most applications will want to construct a FS
instance anyway for testing that doesn't only work on Linux machines.
from procfs.
Is this something that we still want to do? After the refactoring in #149, we still have a lot of method names that look like fs.NewSomething()
. Using the BuddyInfo example, we have NewBuddyInfo()
and fs.NewBuddyInfo()
. We could change the fs method to fs.BuddyInfo()
however the top level function, can't be changed to just BuddyInfo()
because then it conflicts with the BuddyInfo struct. Maybe we can change top level functions to something like ReadBuddyInfo()
instead?
from procfs.
I think the idiomatic way would be to call it BuddyInfo() and rename the struct instead..
from procfs.
See the linked PRs. I think fs.BuddyInfo()
is the way to go and I tend to say we should call the package level functions that do the same should also be called the same but that's somewhat against prefixing "top level constructor functions" with New.. @mdlayher Would love your 2 cents on this.
from procfs.
I still agree with my previous comment: #44 (comment)
I'd like to see very few package level functions, and everything is only accessible via a method on the FS type.
from procfs.
Don't have a opinion on that, so if you think that's better - let's do it.
from procfs.
Fixed in PR #162
from procfs.
Related Issues (20)
- strings.TrimRight is used instead of TrimSuffix HOT 1
- Use Go 1.20+ Error Wrapping
- Release v0.10.0 does not build with GOOS=windows + GOARCH=amd64 HOT 1
- Slice bound out of range on filterOfflineCPUs HOT 4
- CPU vulnerability reporting from sysfs is broken
- Codespell CI job is broken HOT 6
- netstat.go: File handler leak HOT 2
- Infiniband: could not get ARP entries: failed to parse ARP entry HOT 2
- Couldn't parse \"/proc/stat\": bufio.Scanner: token too long HOT 4
- Export mdstat parsing function HOT 6
- No longer compiles on plan9 HOT 3
- code comment error HOT 1
- parseMemInfo() ignores unit, leading to incorrect results from /proc/meminfo HOT 4
- Unknown NFSd metric line "wdeleg_getattr" on kernel 6.6-rc1 HOT 2
- Add the Scorecard Action to monitor procfs' security posture HOT 2
- procfs has data consistency issues when reading /proc/net/tcp HOT 3
- Feature request: procfs TotalFileDescriptorsLen HOT 4
- CmdLine does not parse argv[i] with whitespace correctly HOT 1
- open /proc/stat: too many open files HOT 2
- procfs still unable to collect IB counters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from procfs.