Skip to content

refactor: drop _ prefix and Interface suffix from generated types #50

Description

@pageton

Summary

The code generator produces types with a leading _ prefix and an Interface suffix:

type _QueryInterface[T any] interface { ... }
type _QueryImpl[T any] struct { ... }

Two issues:

  1. _ prefix — In Go, _ is the blank identifier. Using it as a name prefix is non-standard and confuses readers into thinking the variable/type is discarded.
  2. Interface suffix — Per Go convention, interfaces are named after the behavior they describe (e.g. io.Reader, not io.ReaderInterface).

Proposed

type Query[T any] interface { ... }
type QueryImpl[T any] struct { ... }

Since generated code is in the same package as the constructor func Query[T any](...), the unexported interface name queryIface or similar would also work if name clashes are a concern.

Root Cause

  • internal/gen/generator.go:611IfaceName: "_" + n.Name.Name
  • internal/gen/template.go — uses {{$IfaceName}}Interface and {{$IfaceName}}Impl

Affected

All generated output files. The template in internal/gen/template.go and the naming logic in internal/gen/generator.go need updating.

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