From eaf48c9383fb689f1a14f32518d6d90cd0cebd60 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jul 2024 15:20:39 +0200 Subject: [PATCH] types.*: assert interface compliance not stricter than needed I.e. match receivers, don't require a *T if a T is fine, too. --- types/binary.go | 8 ++++---- types/bool.go | 4 ++-- types/unix_milli.go | 6 +++--- types/uuid.go | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/types/binary.go b/types/binary.go index 2a786afe..13362d58 100644 --- a/types/binary.go +++ b/types/binary.go @@ -115,11 +115,11 @@ func (binary Binary) Value() (driver.Value, error) { // Assert interface compliance. var ( - _ fmt.Stringer = (*Binary)(nil) - _ encoding.TextMarshaler = (*Binary)(nil) + _ fmt.Stringer = Binary{} + _ encoding.TextMarshaler = Binary{} _ encoding.TextUnmarshaler = (*Binary)(nil) - _ json.Marshaler = (*Binary)(nil) + _ json.Marshaler = Binary{} _ json.Unmarshaler = (*Binary)(nil) _ sql.Scanner = (*Binary)(nil) - _ driver.Valuer = (*Binary)(nil) + _ driver.Valuer = Binary{} ) diff --git a/types/bool.go b/types/bool.go index cd0af2ce..7de3b5cd 100644 --- a/types/bool.go +++ b/types/bool.go @@ -96,9 +96,9 @@ func (b Bool) Value() (driver.Value, error) { // Assert interface compliance. var ( - _ json.Marshaler = (*Bool)(nil) + _ json.Marshaler = Bool{} _ encoding.TextUnmarshaler = (*Bool)(nil) _ json.Unmarshaler = (*Bool)(nil) _ sql.Scanner = (*Bool)(nil) - _ driver.Valuer = (*Bool)(nil) + _ driver.Valuer = Bool{} ) diff --git a/types/unix_milli.go b/types/unix_milli.go index 943f0799..01dd7c98 100644 --- a/types/unix_milli.go +++ b/types/unix_milli.go @@ -107,10 +107,10 @@ func (t *UnixMilli) fromByteString(data []byte) error { // Assert interface compliance. var ( - _ encoding.TextMarshaler = (*UnixMilli)(nil) + _ encoding.TextMarshaler = UnixMilli{} _ encoding.TextUnmarshaler = (*UnixMilli)(nil) - _ json.Marshaler = (*UnixMilli)(nil) + _ json.Marshaler = UnixMilli{} _ json.Unmarshaler = (*UnixMilli)(nil) - _ driver.Valuer = (*UnixMilli)(nil) + _ driver.Valuer = UnixMilli{} _ sql.Scanner = (*UnixMilli)(nil) ) diff --git a/types/uuid.go b/types/uuid.go index 02acbcdb..6db4b032 100644 --- a/types/uuid.go +++ b/types/uuid.go @@ -20,5 +20,4 @@ func (uuid UUID) Value() (driver.Value, error) { var ( _ encoding.TextUnmarshaler = (*UUID)(nil) _ driver.Valuer = UUID{} - _ driver.Valuer = (*UUID)(nil) )