mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-28 15:05:57 +03:00
Add new admin panel, failover, dns fallback, providers, limiters. Update XHTTP
This commit is contained in:
36
service/manager/repository/postgresql/utils.go
Normal file
36
service/manager/repository/postgresql/utils.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package postgresql
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type stringSliceJSON []string
|
||||
|
||||
func (s *stringSliceJSON) Scan(src interface{}) error {
|
||||
if src == nil {
|
||||
*s = nil
|
||||
return nil
|
||||
}
|
||||
var data []byte
|
||||
switch v := src.(type) {
|
||||
case []byte:
|
||||
data = v
|
||||
case string:
|
||||
data = []byte(v)
|
||||
default:
|
||||
return fmt.Errorf("stringSliceJSON.Scan: unsupported type %T", src)
|
||||
}
|
||||
if len(data) == 0 {
|
||||
*s = nil
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, (*[]string)(s))
|
||||
}
|
||||
|
||||
func marshalStringSlice(values []string) ([]byte, error) {
|
||||
if values == nil {
|
||||
values = []string{}
|
||||
}
|
||||
return json.Marshal(values)
|
||||
}
|
||||
Reference in New Issue
Block a user