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