-
Notifications
You must be signed in to change notification settings - Fork 18k
x/sys/unix: Utsname is using [65]int8 for all its struct members #20753
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
Comments
Changing it in x/sys/unix seems fine to me. We just can't really change any version in the syscall package. |
I agree that we can't change it in syscall. I suppose we could change it in x/sys/unix. It would be nicer going forward, but it could break some existing programs that use it. But there are probably very few, and they are easy to fix. I guess we should change it. Thanks. |
Change https://golang.org/cl/74331 mentions this issue: |
Update golang.org/x/sys to 95c6576299259db960f6c5b9b69ea52422860fce in order to get the unix.Utsname with byte array instead of int8/uint8 members. This allows to use simple byte slice to string conversions instead of using charsToString or its open-coded version. Also see golang/go#20753 for details. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Update golang.org/x/sys to 95c6576299259db960f6c5b9b69ea52422860fce in order to get the unix.Utsname with byte array instead of int8/uint8 members. This allows to use simple byte slice to string conversions instead of using charsToString or its open-coded version. Also see golang/go#20753 for details. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Update golang.org/x/sys to 95c6576299259db960f6c5b9b69ea52422860fce in order to get the unix.Utsname with byte array instead of int8/uint8 members. This allows to use simple byte slice to string conversions instead of using charsToString or its open-coded version. Also see golang/go#20753 for details. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Upstream-commit: 6d068bc Component: engine
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.4 linux/amd64
What operating system and processor architecture are you using (
go env
)?OARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mvo/devel/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build701945664=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
I want to get information from unix.Uname() - this works fine, however the fact that
Utsname
has all members as int8 is making working with the result a bit cumbersome. It would be simpler if this would be a [65]byte instead because than the bytes package can be used on it. Unless I miss something the only ways to convert this are:What did you expect to see?
Ideally a simple
println(string(utsname.Machine[:]))
would be enough to convert it to a string without the need for the unsafe.Pointer() casting.I am happy to work on a PR if there is a chance for this to get accepted.
The text was updated successfully, but these errors were encountered: