From 49a7790edc4ec9526a7b846399339068990ce7de Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Mon, 6 Jan 2025 13:11:33 +0100 Subject: remove go:linkname usage --- option/option.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'option/option.go') diff --git a/option/option.go b/option/option.go index e8d7fb4..992c7b7 100644 --- a/option/option.go +++ b/option/option.go @@ -118,8 +118,6 @@ import ( "encoding/json" "fmt" "iter" - - "github.com/majewsky/gg/internal/hack" ) // Option is a type that contains either one or no instances of T. @@ -328,19 +326,18 @@ type yamlMarshaler interface { // Scan implements the database/sql.Scanner interface. func (o *Option[T]) Scan(src any) error { - switch src := src.(type) { - case nil: + var data sql.Null[T] + err := data.Scan(src) + if err != nil { + return err + } + + if data.Valid { + *o = Some(data.V) + } else { *o = None[T]() - return nil - default: - var data T - err := hack.ConvertAssign(&data, src) - if err != nil { - return err - } - *o = Some(data) - return nil } + return nil } // Value implements the database/sql/driver.Valuer interface. -- cgit v1.2.3