~netlandish/gobwebs

e6cc7251af76f15521fcf0d69107fc4dbb4fa731 — Peter Sanchez 2 months ago c7bf12b v0.1.1
Adding sql integration for Map type
1 files changed, 20 insertions(+), 0 deletions(-)

M gobwebs.go
M gobwebs.go => gobwebs.go +20 -0
@@ 1,5 1,11 @@
package gobwebs

import (
	"database/sql/driver"
	"encoding/json"
	"errors"
)

const (
	// LoginTypeAuth use normal email/password auth
	LoginTypeAuth int = iota


@@ 9,3 15,17 @@ const (

// Map is a global mapping type
type Map map[string]any

// Value for sql integration
func (m Map) Value() (driver.Value, error) {
	return json.Marshal(m)
}

// Scan for sql integration
func (m *Map) Scan(value interface{}) error {
	b, ok := value.([]byte)
	if !ok {
		return errors.New("type assertion to []byte failed")
	}
	return json.Unmarshal(b, &m)
}

Do not follow this link