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

syscall.Stat_t with different fields' name between Darwin and Linux #32887

Open
mcspring opened this issue Jul 2, 2019 · 3 comments

Comments

@mcspring
Copy link
Contributor

commented Jul 2, 2019

What version of Go are you using (go version)?

$go version

go version go1.12.6 darwin/amd64

Does this issue reproduce with the latest release?

YES!

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/MC/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/MC/Golang/pkgs"
GOPROXY=""
GORACE=""
GOROOT="/Users/MC/Golang/go"
GOTMPDIR=""
GOTOOLDIR="/Users/MC/Golang/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/MC/Workspaces/qutoutiao/godis/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/th/22jxv0q12c5c23v02rt67gg00000gp/T/go-build623000608=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Access file ctime from os.FileInfo;

https://play.golang.org/p/LD80qQy5qyC

What did you expect to see?

All os.FileInfo.Sys() should have the same fields' name across OS.

What did you see instead?

Within Linux OS, it should call Stat_t.Ctim.Sec; But under Darwin OS, you have Stat_t.Ctimespec.Sec in hand.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2019

Unfortunately I don't think we can change this now. It would break existing programs.

@bcmills bcmills added the Unfortunate label Jul 2, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Jul 2, 2019

In #18130 (comment), I suggested struct field aliases as a next step after type aliases. That would allow the two platforms to be unified by defining one of the field names as an alias for the other.

That would, however, require a language change.

@bcmills bcmills added this to the Unplanned milestone Jul 2, 2019

@mcspring

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.