File size: 477 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package alertlog

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

type rawJSON json.RawMessage

func (r *rawJSON) Scan(value interface{}) error {
	switch t := value.(type) {
	case []byte:
		buf := make([]byte, len(t))
		copy(buf, t)
		*r = rawJSON(buf)
	case nil:

	default:
		return fmt.Errorf("could not process unknown type %T", t)
	}

	return nil
}
func (r rawJSON) Value() (driver.Value, error) {
	if len(r) == 0 {
		return nil, nil
	}
	return []byte(r), nil
}