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

False positive on embedded types #1443

Closed
fogfish opened this issue Aug 26, 2023 · 2 comments
Closed

False positive on embedded types #1443

fogfish opened this issue Aug 26, 2023 · 2 comments

Comments

@fogfish
Copy link

fogfish commented Aug 26, 2023

Minimal code to represent issue

type A string

type B struct {
	A `json:"a"`
}

func TestXXX(t *testing.T) {
	x := B{}

	// struct type 'B' doesn't have any exported fields,
	// nor custom marshaling (SA9005)go-staticcheck
	b, _ := json.Marshal(x)
	fmt.Printf("%s\n", string(b))
}
staticcheck -version
staticcheck 2023.1.5 (v0.4.5)
staticcheck -debug.version
staticcheck 2023.1.5 (v0.4.5)

Compiled with Go version: go1.20.4
Main module:
	honnef.co/go/tools@v0.4.5 (sum: h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo=)
Dependencies:
	github.com/BurntSushi/toml@v1.2.1 (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=)
	golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=)
	golang.org/x/mod@v0.10.0 (sum: h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=)
	golang.org/x/sys@v0.8.0 (sum: h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=)
	golang.org/x/tools@v0.9.4-0.20230601214343-86c93e8732cc (sum: h1:mqZawFxUzsv+YVwGQO30cZegeV/YD6dAwsdGxi0tQQg=)
go version
go version go1.20.4 darwin/arm64
go env

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/kolesnik/Library/Caches/go-build"
GOENV="/Users/kolesnik/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kolesnik/devel/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kolesnik/devel/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kolesnik/devel/go/src/github.com/fogfish/schemaorg/schemaext/go.mod"
GOWORK="/Users/kolesnik/devel/go/src/github.com/fogfish/schemaorg/go.work"
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/98/0ttsxqrn6q13jwh9shqc30jr0000gn/T/go-build2539534517=/tmp/go-build -gno-record-gcc-switches -fno-common"
@fogfish fogfish added false-positive needs-triage Newly filed issue that needs triage labels Aug 26, 2023
@dominikh dominikh removed the needs-triage Newly filed issue that needs triage label Aug 26, 2023
@dominikh
Copy link
Owner

Fascinating. Will fix.

@fogfish
Copy link
Author

fogfish commented Aug 26, 2023

Thank you

dominikh added a commit that referenced this issue Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants