From 17c36159c4f24e4959b5f2276e58cfaf90c5456b Mon Sep 17 00:00:00 2001 From: James Warren Date: Mon, 18 Jun 2018 17:46:42 +0100 Subject: [PATCH] fix(tpl): struct pointer reference --- tmpl.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmpl.go b/tmpl.go index 0a9dc67..32abbd4 100644 --- a/tmpl.go +++ b/tmpl.go @@ -11,7 +11,7 @@ import ( ) {{range .Tokens}} func {{$.Visibility}}can{{title .Name}}(r *sql.Row) (*{{pkg .Name}}, error) { - var s *{{pkg .Name}} + s := &{{pkg .Name}}{} if err := r.Scan({{range .Fields}} &s.{{.Name}},{{end}} ); err != nil { @@ -24,7 +24,7 @@ func {{$.Visibility}}can{{title .Name}}s(rs *sql.Rows) ([]*{{pkg .Name}}, error) structs := make([]*{{pkg .Name}}, 0, 16) var err error for rs.Next() { - var s *{{pkg .Name}} + s := &{{pkg .Name}}{} if err = rs.Scan({{range .Fields}} &s.{{.Name}},{{end}} ); err != nil {