You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Wingrez\AppData\Local\go-build
set GOENV=C:\Users\Wingrez\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\workspace\my\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=*set GOOS=windows
set GOPATH=D:\workspace\my\go
set GOPRIVATE=
set GOPROXY=http://cmc-cd-mirror.rnd.huawei.com/goproxy,direct
set GOROOT=D:\workspace\git\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\workspace\git\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.22-b7c630dc3a Tue Jan 9 01:36:54 2024 +0000
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\Wingrez\AppData\Local\Temp\go-build3833231449=/tmp/go-build -gno-record-gcc-switches
What did you do?
I compiled the same code using go1.22 and go1.19.3, but the results were different.
This is my code:
Package initialization order is now specified more precisely. The new algorithm is:
Sort all packages by import path.
Repeat until the list of packages is empty:
Find the first package in the list for which all imports are already initialized.
Initialize that package and remove it from the list.
This may change the behavior of some programs that rely on a specific initialization ordering that was not expressed by explicit imports. The behavior of such programs was not well defined by the spec in past releases. The new rule provides an unambiguous definition.
Go version
go version devel go1.22-b7c630dc3a
Output of
go env
in your module/workspace:What did you do?
I compiled the same code using go1.22 and go1.19.3, but the results were different.
This is my code:
main.go
pkg1/init.go
pkg2/init.go
What did you see happen?
Using go1.19.3, the result is:
Using go1.22, the result is:
What did you expect to see?
I think the result from go1.19.3 is correct. Not sure if Go's specifications have changed.
The text was updated successfully, but these errors were encountered: