MCPcopy Index your code
hub / github.com/Masterminds/structable / structField

Function structField

schema2struct/schema2struct.go:271–287  ·  view source on GitHub ↗
(c *column, pks []string, tbl string, b squirrel.StatementBuilderType)

Source from the content-addressed store, hash-verified

269}
270
271func structField(c *column, pks []string, tbl string, b squirrel.StatementBuilderType) string {
272 tpl := "%s %s `stbl:\"%s\"`"
273 gn := goName(c.Name)
274 tt := goType(c.DataType)
275
276 tag := c.Name
277 for _, p := range pks {
278 if c.Name == p {
279 tag += ",PRIMARY_KEY"
280 if sequentialKey(tbl, c.Name, b) {
281 tag += ",SERIAL"
282 }
283 }
284 }
285
286 return fmt.Sprintf(tpl, gn, tt, tag)
287}
288
289// goType takes a SQL type and returns a string containin the name of a Go type.
290//

Callers 1

importTableFunction · 0.85

Calls 3

goNameFunction · 0.85
goTypeFunction · 0.85
sequentialKeyFunction · 0.85

Tested by

no test coverage detected