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
Open

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

mcspring opened this issue Jul 2, 2019 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Milestone

Comments

@mcspring
Copy link
Contributor

mcspring 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
Copy link
Contributor

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

@bcmills
Copy link
Contributor

bcmills 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
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 2, 2019
@mcspring
Copy link
Contributor Author

mcspring commented Jul 5, 2019 via email

@seankhliao seankhliao changed the title syscall.Stat_t with different fields' name between Darwin and Linux syscall: Stat_t with different fields' name between Darwin and Linux Jan 25, 2021
alexcb pushed a commit to alexcb/fsutil that referenced this issue Jun 8, 2021
These wrappers replace the use of the utility functions in
github.com/containerd/containerd/sys, and work around
golang/go#32887.

The implementations were derived from
https://golang.org/search?q=Stat_t#Global_pkg/syscall

Hence, containerd/containerd is no longer used and can be removed as a
dependency, which also removes Microsoft/hcsshim.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Projects
None yet
Development

No branches or pull requests

4 participants