We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e088da7 commit 52b6bb4Copy full SHA for 52b6bb4
1 file changed
internal/codegen/golang/struct.go
@@ -2,6 +2,8 @@ package golang
2
3
import (
4
"strings"
5
+ "unicode"
6
+ "unicode/utf8"
7
8
"github.com/kyleconroy/sqlc/internal/plugin"
9
)
@@ -25,5 +27,12 @@ func StructName(name string, settings *plugin.Settings) string {
25
27
out += strings.Title(p)
26
28
}
29
- return out
30
+
31
+ // If a name has a digit as its first char, prepand an underscore to make it a valid Go name.
32
+ r, _ := utf8.DecodeRuneInString(out)
33
+ if unicode.IsDigit(r) {
34
+ return "_" + out
35
+ } else {
36
+ return out
37
+ }
38
0 commit comments