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

Struct member not initialised #31208

Closed
cristizmf opened this issue Apr 2, 2019 · 4 comments
Closed

Struct member not initialised #31208

cristizmf opened this issue Apr 2, 2019 · 4 comments

Comments

@cristizmf
Copy link

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

$ go version
go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env GOARCH="amd64" GOBIN="" GOCACHE="removed" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="removed" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" 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/9w/jk857_nn2z99k31qsg9pbwjr0000gn/T/go-build429491925=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In certain situations when a struct has a member of type interface and is initialised with a value it will still be nil. I was able to create a sample in Go Playground to reproduce it:

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

Struct member "Height" is nil in that example when it should be "Height:{V:0}"

Just by playing a bit with the code you can make it work:

What did you expect to see?

{Name:some prop Title: Height:{V:0}}

What did you see instead?

{Name:some prop Title: Height:}

@randall77
Copy link
Contributor

I can confirm that this is broken on 1.12. It is fixed on tip, however.

@randall77
Copy link
Contributor

I believe the fix was https://go-review.googlesource.com/c/go/+/168858/ for issue #30956.

@cristizmf
Copy link
Author

Thanks! It does indeed look like a duplicate.

@randall77
Copy link
Contributor

Closing as a dup.

@golang golang locked and limited conversation to collaborators Apr 1, 2020
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