3
0

Add some nil checks to typed values

This commit is contained in:
Tomaž Jerman
2024-07-09 12:14:29 +02:00
committed by Jože Fortun
parent f17a9da29c
commit c3bf35eee1
6 changed files with 268 additions and 0 deletions

View File

@@ -27,6 +27,10 @@ func (r {{.expIdent}}) GetID() (uint64) {
}
func (r *{{.expIdent}}) GetValue(name string, pos uint) (any, error) {
if r == nil {
return nil, nil
}
switch name {
{{ range .model.attributes -}}
{{- if .omitGetter -}}
@@ -48,6 +52,10 @@ func (r *{{.expIdent}}) GetValue(name string, pos uint) (any, error) {
}
func (r *{{.expIdent}}) SetValue(name string, pos uint, value any) (err error) {
if r == nil {
r = &{{.expIdent}}{}
}
switch name {
{{ range .model.attributes -}}
{{- if .omitSetter -}}