Skip to content

Commit

Permalink
Introduce types.MakeString()
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Mar 25, 2024
1 parent 41ff8de commit e2fc769
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/types/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e2fc769

Please sign in to comment.