Skip to content

Replace Config.OpenFile with more general fs.FS-based approach - #296

Draft
benhoyt wants to merge 1 commit into
masterfrom
filesystem
Draft

Replace Config.OpenFile with more general fs.FS-based approach#296
benhoyt wants to merge 1 commit into
masterfrom
filesystem

Conversation

@benhoyt

@benhoyt benhoyt commented Jul 28, 2026

Copy link
Copy Markdown
Owner

In #294 we added Config.OpenFile, but it returned a concrete *os.File, which makes it a lot less flexible than it needs to be. As this version hasn't been released yet, let's see if we can improve that.

I'd like to fit in with io/fs.FS if possible, so that's what I've tried to do: if you provide a bare fs.FS for Config.FileSystem it allows read-only file access. If the type also implements WriteFS (adding Create and Append methods) it allow read and write access.

NOTE: This code was written with the help of AI (GLM 5.2). I've reviewed it a little bit, but not thoroughly yet. This is a draft to see if we like the idea.

In #294 we added Config.OpenFile, but it returned a concrete *os.File,
which makes it a lot less flexible than it needs to be. As this version
hasn't been released yet, let's see if we can improve that.

I'd like to fit in with io/fs.FS if possible, so that's what I've tried
to do: if you provide a bare fs.FS for Config.FileSystem it allows
read-only file access. If the type also implements WriteFS (adding
Create and Append methods) it allow read and write access.

NOTE: This code was written with the help of AI (GLM 5.2). I've
reviewed it a little bit, but not thoroughly yet. This is a draft to
see if we like the idea.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant