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
Copy file name to clipboardExpand all lines: README.md
+59-12Lines changed: 59 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,9 @@
1
1
# gobetter - Go Builder Pattern Generator
2
2
3
-
**gobetter** is a code generator that creates type-safe builder patterns for Go structs, enforcing mandatory fields at compile time through a fluent API similar to named arguments.
3
+
**gobetter** is a code generator that creates type-safe builder patterns for Go structs, enforcing
4
+
mandatory fields at compile time through a fluent API similar to named arguments.
4
5
5
-
## ✨ Features
6
+
## Features
6
7
7
8
-**Compile-time safety** - Missing mandatory fields cause compilation errors
8
9
-**IDE-friendly** - Excellent autocomplete support showing only the next required field
@@ -11,12 +12,12 @@
11
12
-**Struct tag preservation** - Maintains JSON, validation, and other struct tags
12
13
-**Flexible configuration** - Control visibility, optional fields, and generation scope
13
14
14
-
## 🎬 Demo
15
+
**IDE Autocomplete (no plugin needed)** - Only shows the next mandatory field:
15
16
16
-
**IDE Autocomplete** - Only shows the next mandatory field:
17
17

18
18
19
19
**Compile-time Validation** - Missing fields cause compilation errors:
20
+
20
21

21
22
22
23
## The Problem
@@ -28,7 +29,7 @@ type Person struct {
28
29
FirstNamestring
29
30
LastNamestring
30
31
Ageint
31
-
Descriptionstring// optional field
32
+
Descriptionstring
32
33
}
33
34
34
35
// Traditional struct initialization
@@ -40,20 +41,66 @@ person := Person{
40
41
}
41
42
```
42
43
43
-
**Problems with traditional approaches:**
44
-
-❌ Easy to forget required fields
45
-
-❌ No compile-time validation
46
-
-❌ Manual constructor functions need constant maintenance
47
-
-❌ Parameter order mistakes (no named parameters in Go)
44
+
**Where this breaks down:**
45
+
-Missing required fields still compile (zero values sneak in).
46
+
-Refactors are risky: adding a required field means hunting every construction site.
47
+
-Constructors are order‑sensitive and error‑prone; many code generators don’t emit them at all.
0 commit comments