automatically ignore known forwarded addresses, fixes #64

This commit is contained in:
Aine
2023-09-18 12:35:37 +03:00
parent e90925eceb
commit 60b4386dd8
187 changed files with 4070 additions and 2667 deletions

33
vendor/go.mau.fi/util/dbutil/json.go vendored Normal file
View File

@@ -0,0 +1,33 @@
package dbutil
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
// JSON is a utility type for using arbitrary JSON data as values in database Exec and Scan calls.
type JSON struct {
Data any
}
func (j JSON) Scan(i any) error {
switch value := i.(type) {
case nil:
return nil
case string:
return json.Unmarshal([]byte(value), j.Data)
case []byte:
return json.Unmarshal(value, j.Data)
default:
return fmt.Errorf("invalid type %T for dbutil.JSON.Scan", i)
}
}
func (j JSON) Value() (driver.Value, error) {
if j.Data == nil {
return nil, nil
}
v, err := json.Marshal(j.Data)
return string(v), err
}