Skip to content

stylecheck: add a check similar to ST1020, ST1021, ST1022 for struct field documentation #1635

Open
@ainar-g

Description

@ainar-g

(I've searched the issue tracker, but it seems that this has never been brought up. If I'm wrong, feel free to close.)

package main

import "fmt"

// NotT is a type.
type T struct {
	// A is a field.
	A int

	// A is a field.
	B int
}

func main() {
	fmt.Println(T{})
}
staticcheck --version
staticcheck 2025.1 (0.6.0)
staticcheck --checks='*' ./main.go
  • Got:

    main.go:5:1: comment on exported type T should be of the form "T ..." (with optional leading article) (ST1021)
    
  • Expected:

    main.go:5:1: comment on exported type T should be of the form "T ..." (with optional leading article) (ST1021)
    main.go:10:2: comment on exported Field B should be of the form "B ..." (with optional leading article) (ST10XX)
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionWe have to decide if this check is feasible and desirablenew-check

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions