~repos /gromer
git clone https://pyrossh.dev/repos/gromer.git
gromer is a framework and cli to build multipage web apps in golang using htmx and alpinejs.
2b1a6b29
—
Peter John 4 years ago
Fix field name
- cmd/gromer/main.go +11 -5
cmd/gromer/main.go
CHANGED
|
@@ -173,8 +173,10 @@ func main() {
|
|
|
173
173
|
if st, ok := typeSpec.Type.(*ast.StructType); ok {
|
|
174
174
|
mapsOfInputParams[typeSpec.Name.Name] = map[string]interface{}{}
|
|
175
175
|
for _, f := range st.Fields.List {
|
|
176
|
+
if len(f.Names) > 0 {
|
|
176
|
-
|
|
177
|
+
fieldName := lowerFirst(f.Names[0].Name)
|
|
177
|
-
|
|
178
|
+
mapsOfInputParams[typeSpec.Name.Name][fieldName] = fmt.Sprintf("%+s", f.Type)
|
|
179
|
+
}
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
}
|
|
@@ -184,9 +186,13 @@ func main() {
|
|
|
184
186
|
if decl.Name.Name == method {
|
|
185
187
|
list := decl.Type.Params.List
|
|
186
188
|
lastParam := list[len(list)-1]
|
|
189
|
+
if spec, ok := lastParam.Type.(*ast.Ident); ok {
|
|
190
|
+
if spec.IsExported() {
|
|
187
|
-
|
|
191
|
+
// TODO: need to read from imported files and pick up the struct and
|
|
192
|
+
// convert it to json
|
|
188
|
-
|
|
193
|
+
} else if v, ok := mapsOfInputParams[spec.Name]; ok {
|
|
189
|
-
|
|
194
|
+
params = v
|
|
195
|
+
}
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
198
|
}
|