3 Commits

Author SHA1 Message Date
clawbot
d83bd08d4d style: fix prettier formatting in constructor naming section
All checks were successful
check / check (push) Successful in 6s
2026-03-17 21:41:33 -07:00
user
4c643d1aa2 style: Params struct required even for single arguments
Only exception: stupidly obvious single args (featureflag.New(true)).
When in doubt, use Params.
2026-03-17 21:41:33 -07:00
user
e72b2d3522 style: strengthen constructor naming and Params struct rules
- Constructors must be New(), From<Something>(), or NewThing() (multi-type pkg)
- Strongly discourage creative names (Create, Make, Build, Init)
- Constructors must use Params struct for 2+ arguments, no exceptions
- Single obvious argument (ctx, bytes) is the only exception
2026-03-17 21:41:33 -07:00

View File

@@ -138,13 +138,13 @@ last_modified: 2026-02-22
1. Constructors **must** be called `New()`. `modulename.New()` works great if
you name the packages properly. If the constructor creates an instance from
an existing value or representation, `From<Something>()` (e.g. `FromBytes()`,
`FromConfig()`) is also acceptable. If the package contains multiple types
and `New()` is ambiguous, `NewThing()` is occasionally acceptable — but
prefer restructuring packages so each type gets its own package and a plain
`New()`. Do not invent creative constructor names like `Create()`, `Make()`,
`Build()`, `Open()` (unless wrapping an OS resource), or `Init()`. If you
see a constructor with a non-standard name, rename it.
an existing value or representation, `From<Something>()` (e.g.
`FromBytes()`, `FromConfig()`) is also acceptable. If the package contains
multiple types and `New()` is ambiguous, `NewThing()` is occasionally
acceptable — but prefer restructuring packages so each type gets its own
package and a plain `New()`. Do not invent creative constructor names like
`Create()`, `Make()`, `Build()`, `Open()` (unless wrapping an OS resource),
or `Init()`. If you see a constructor with a non-standard name, rename it.
1. Don't make packages too big. Break them up.