Skip to content

os: add File.Chown on the unix path - #5589

Merged
dgryski merged 1 commit into
tinygo-org:devfrom
0magnet:os-file-chown
Aug 18, 2026
Merged

os: add File.Chown on the unix path#5589
dgryski merged 1 commit into
tinygo-org:devfrom
0magnet:os-file-chown

Conversation

@0pcom

@0pcom 0pcom commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

os.File.Chown is missing on unix targets, so code calling it fails to compile even though os.Chown (the path-based form) is present and the syscall is already available.

This adds the method on the unix path, delegating to the same syscall the package-level function uses.

Verified by building TinyGo.

Comment thread src/os/file_unix.go Outdated
}

// Chown changes the numeric uid and gid of the named file. It mirrors Truncate:
// the unix os.File was missing this method (it exists only on the baremetal/wasm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the history of the change is not necessary to stay as a code comment when its not relevant to the implementation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Please change the comment to simply document os.Chown.

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.
@0pcom

0pcom commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks both — comment reduced to documenting the method, matching the wording of the package-level Chown in file_anyos.go. Rebased on dev.

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@b0ch3nski b0ch3nski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dgryski
dgryski merged commit ac45c35 into tinygo-org:dev Aug 18, 2026
20 checks passed
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.

3 participants