Skip to content
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

os/user: functions aren't implemented on Linux/386 #10868

Closed
fd0 opened this issue May 15, 2015 · 2 comments
Closed

os/user: functions aren't implemented on Linux/386 #10868

fd0 opened this issue May 15, 2015 · 2 comments

Comments

@fd0
Copy link

fd0 commented May 15, 2015

I'm using Go 1.4.2 on Linux/amd64 and was unpleasantly surprised that the functions in the os/user package aren't implemented for GOARCH=386, e.g. a call to `user.

$ cat usertest.go
package main

import (
    "fmt"
    "os/user"
)

func main() {
    u, err := user.Current()
    fmt.Printf("current user: %#v %#v\n", u, err)
}

$ GOARCH=amd64 go run usertest.go 
current user: &user.User{Uid:"1000", Gid:"1000", Username:"fd0", Name:"Alexander Neumann", HomeDir:"/home/fd0"} <nil>

$ GOARCH=386 go run usertest.go 
current user: (*user.User)(nil) &errors.errorString{s:"user: Current not implemented on linux/386"}

I would expect that the functions work as advertised, it sad that there are functions in the stdlib that (at least for me as a user) just don't work on some architectures. Is this documented somewhere and I overlooked it?

What's the reason for this?

@minux minux closed this as completed May 15, 2015
@minux
Copy link
Member

minux commented May 15, 2015

os/user needs cgo to function properly, but cgo is disabled
when cross compiling. you need to set CGO_ENABLED=1
explicitly.

CGO_ENABLED=1 GOARCH=386 go run usertest.go

@mikioh mikioh changed the title os/user functions aren't implemented on Linux/386 os/user: functions aren't implemented on Linux/386 May 15, 2015
@fd0
Copy link
Author

fd0 commented May 15, 2015

Thanks a lot for this clarification! (At least there is an issue here that others can find via Google).

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants