From e2fc7695e07062a3b382d4dc74c5a67ec75aac7a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 13 Mar 2024 16:01:41 +0100 Subject: [PATCH] Introduce types.MakeString() --- pkg/types/string.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/types/string.go b/pkg/types/string.go index f8ead450c..ce2a4ac69 100644 --- a/pkg/types/string.go +++ b/pkg/types/string.go @@ -15,6 +15,14 @@ type String struct { sql.NullString } +// MakeString constructs a new non-NULL String from s. +func MakeString(s string) String { + return String{sql.NullString{ + String: s, + Valid: true, + }} +} + // MarshalJSON implements the json.Marshaler interface. // Supports JSON null. func (s String) MarshalJSON() ([]byte, error) {