New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: os: Chown expects int, but os/user uses strings #6495
Comments
Not sure what chown does on Windows, but consider: 1. Windows claims POSIX compatibility 2. The implementation of os.Chown http://golang.org/src/pkg/os/file_posix.go#L98 is explicitly used on Windows: http://golang.org/src/pkg/os/file_posix.go#L5 -- that is, it's not a stub like on Plan 9: http://golang.org/src/pkg/os/file_plan9.go#L408 |
> ... 1. Windows claims POSIX compatibility You should take it up with Microsoft. > 2. The implementation of os.Chown http://golang.org/src/pkg/os/file_posix.go#L98 > is explicitly used on Windows: http://golang.org/src/pkg/os/file_posix.go#L5 > -- that is, it's not a stub like on Plan 9: > http://golang.org/src/pkg/os/file_plan9.go#L408 Oh, it is the same as plan9: http://golang.org/src/pkg/syscall/syscall_windows.go#L901 And you didn't tell us what you are trying to accomplish with Chown on windows. I don't see us doing anything until we have some plan. Alex |
cf #8537 |
The os package does provide So the question is whether we should add a conversion function from the os/user package representation ( Perhaps the os/user package should have Unix-specific functions It's not clear whether there is any corresponding requirement on Windows. |
Rather than focus on how to fix this particular mismatch, I'd rethink the whole I mean, |
os/user was designed to work with Windows, hence the strings. But os.Chown etc return ErrWindows on Windows. I'm thinking we should create new interface types for OS users and groups (similar to os.Signal), and then concrete implementations with int & string underlying types, something like: package xxx
type User interface{
unexported()
}
type UserID int
func (UserID) unexported() {}
type UserName string
func (UserName) unexported() {} And then use the |
Seems weird to be forced to make string comparisons when:
You are really going to cripple everyone but windows for the sake of windows bad choices? Just make a separate library for windows and leave the standard library efficient as possible. |
The text was updated successfully, but these errors were encountered: