You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The linter checks that the Structures are created by the Factory, and not directly.
9
9
10
10
The checking helps to provide invariants without exclusion and helps avoid creating an invalid object.
11
11
12
12
13
-
## Use
13
+
## Usage
14
14
15
-
Installation
15
+
### Installation
16
16
17
-
go install github.com/maranqz/go-factory-lint/cmd/go-factory-lint@latest
17
+
go install github.com/maranqz/gofactory/cmd/gofactory@latest
18
18
19
19
### Options
20
20
21
-
-`--packageGlobs` - list of glob packages, which can create structures without factories inside the glob package. By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs).
22
-
-`onlyPackageGlobs` - use a factory to initiate a structure for glob packages only, [tests](testdata/src/factory/onlyPackageGlobs).
21
+
-`--packageGlobs` – list of glob packages, which can create structures without factories inside the glob package.
22
+
By default, all structures from another package should be created by factories, [tests](testdata/src/factory/packageGlobs).
23
+
-`--packageGlobsOnly` – use a factory to initiate a structure for glob packages only,
24
+
[tests](testdata/src/factory/packageGlobsOnly). Doesn't make sense without `--packageGlobs`.
23
25
24
26
## Example
25
27
@@ -128,6 +130,7 @@ Linter doesn't catch some cases.
128
130
2. Local initialization, [example](testdata/src/factory/unimplemented/local/).
129
131
3. Named return. If you want to block that case, you can use [nonamedreturns](https://github.com/firefart/nonamedreturns) linter, [example](testdata/src/factory/unimplemented/named_return.go).
130
132
4. var declaration, `var initilized nested.Struct` gives structure without factory, [example](testdata/src/factory/unimplemented/var.go).
133
+
To block that case, you can use [gopublicfield](github.com/maranqz/gopublicfield) to prevent fill of structure fields.
0 commit comments