golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.19k stars 17.57k forks source link

go vet fail composite literal uses unkeyed fields #32100

Closed orange-jacky closed 5 years ago

orange-jacky commented 5 years ago

Please answer these questions before submitting your issue. Thanks!

What did you do?

i use package "go.mongodb.org/mongo-driver/bson"

.... filter := bson.D{{"sp.inserttime", bson.D{{"$gte", int64(timestamp)}}}} ctx := context.Background() cur, err := collection.Find(ctx, filter) ....

go build my code, it success

meanwhile, go vet it, an it failed

What did you expect to see?

go vet ok

What did you see instead?

go.mongodb.org/mongo-driver/bson/primitive.E composite literal uses unkeyed fields

System details

go version go1.12.5 darwin/amd64
GOARCH="amd64"
GOBIN="/Users/fredlee/Documents/develop/go/workspace/bin"
GOCACHE="/Users/fredlee/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/fredlee/Documents/develop/go/workspace"
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="/dev/null"
GOROOT/bin/go version: go version go1.12.5 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.5
uname -v: Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64
ProductName:    Mac OS X
ProductVersion: 10.14.1
BuildVersion:   18B75
lldb --version: lldb-1000.11.38.2
  Swift-4.2
ianlancetaylor commented 5 years ago

This is working as expected. This is the vet test "composites", documented as "check for unkeyed composite literals". I'm going to close this bug since this is what is supposed to happen. Please comment if I have misunderstood.