Re:Show HN: A new stdlib for Golang focusing on platform nat...
by flkenosad on Tuesday October 03, 2023 @08:54AM
(#37751210)
Is the new std lib a re-implementation of the existing std lib or are you defining brand new interfaces as well? For example, will you still have an `os.WriteFile` and will its still take the same parameters and return the same results?
[ Parent
| on HN ]
Re:Show HN: A new stdlib for Golang focusing on platform nat...
by Leotard6963 on Tuesday October 03, 2023 @09:42AM
(#37751826)
Yes, we are re-implementing (some of) the official std, but with careful redesign, and probably won't provide a lot of familiar apis, this is largely because packages from the official std often do implicit allocations with the assumption of GC running.
And Yes, we are defining brand new interfaces as well, in order to improve usability and fix inconsistent user experience.
For your specific example `os.WriteFile` (names mentioned below may subject to change):
The api won't make it inside the std, because the local filesystem will be implemented as a `fs.FS` (concrete type `*sysfs.FS`), so you can have multiple `sysfs.FS` instances each at its own working directory, and the `os.WriteFile` will be replaced with `fs.WriteFile(fsys fs.FS, path *fs.PathBuf, wctx *io.WriteContext) io.Status`, where `fs.PathBuf` is our solution to handle all kinds of path styles (windows, unix, cygwin, utf8, utf16, end-null) and operations (join, base, dir).