Skip to content

wikipedia: example fails go vet on unkeyed SearchRequest literal #968

Description

@dajiaohuang

Description

The Wikipedia example constructs the exported wikipedia.SearchRequest type with an unkeyed struct literal:

wikipedia.SearchRequest{"bytedance"}

On current main (6752ff8da9b1ea85c8e91b27b0a64fef099f22f9), the repository's documented vet check reports:

components/tool/wikipedia/examples/main.go:49:32: wikipedia.SearchRequest struct literal uses unkeyed fields

Because the type belongs to another package, the unkeyed literal also couples the example to field order and will silently target the wrong field if fields are reordered.

Reproduction

From components/tool/wikipedia with Go 1.25.6 on Linux:

go vet ./...

Expected behavior

The example should pass go vet and name the request field explicitly.

Suggested fix

Use wikipedia.SearchRequest{Query: "bytedance"}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions