diff options
| author | Shulhan <ms@kilabit.info> | 2026-03-26 02:12:10 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-03-26 02:12:10 +0700 |
| commit | b6ba871a86797ad2f028eab2e3820509c3a36109 (patch) | |
| tree | 14ff0cbf3983860f9799ab27cfbe25434d46060c | |
| parent | 03d4328eb4db5e80fe8ad1df14c3f73bc33c9190 (diff) | |
| download | pakakeh.go-b6ba871a86797ad2f028eab2e3820509c3a36109.tar.xz | |
lib/uuidv7: implements method Value from [driver.Valuer]
The Value method returns the value for sending it to the
database.
| -rw-r--r-- | lib/uuidv7/uuidv7.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/uuidv7/uuidv7.go b/lib/uuidv7/uuidv7.go index 6870b562..e35e684b 100644 --- a/lib/uuidv7/uuidv7.go +++ b/lib/uuidv7/uuidv7.go @@ -6,6 +6,7 @@ package uuidv7 import ( "crypto/rand" + "database/sql/driver" "encoding/binary" "encoding/hex" "fmt" @@ -217,3 +218,10 @@ func (id *UUIDv7) Time() time.Time { t := time.UnixMilli(int64(millis)) return t } + +// Value returns the value for sending it to the database. +// This method implements the [driver.Valuer] interface. +func (id UUIDv7) Value() (v driver.Value, err error) { + v = id.String() + return v, nil +} |
