From 1a6b051e8e2d583b141d675b78a2555f782805ab Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Thu, 16 Jul 2026 09:01:30 -0500 Subject: [PATCH] os: add File.Chown on the unix path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit file_unix.go (darwin/linux/wasip) was missing the exported (*File).Chown method that file_other.go (baremetal/wasm) already has, so callers requiring the full os.File surface — e.g. github.com/pkg/sftp — failed to compile for the linux/amd64 TinyGo target. Delegates to the package-level Chown, mirroring (*File).Truncate. --- src/os/file_unix.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/os/file_unix.go b/src/os/file_unix.go index 997894eaad..d091c65c59 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -163,6 +163,17 @@ func (f *File) Truncate(size int64) (err error) { return Truncate(f.name, size) } +// Chown changes the numeric uid and gid of the named file. +// A uid or gid of -1 means to not change that value. +// If there is an error, it will be of type *PathError. +func (f *File) Chown(uid, gid int) error { + if f.handle == nil { + return ErrClosed + } + + return Chown(f.name, uid, gid) +} + func (f *File) chmod(mode FileMode) error { if f.handle == nil { return ErrClosed