mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-07-04 17:06:49 +00:00
New lint rules
This commit is contained in:
@ -18,7 +18,7 @@ func (d DBDate) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
// Scan takes data from the database and modifies it for Go Types
|
||||
func (d *DBDate) Scan(src interface{}) error {
|
||||
func (d *DBDate) Scan(src any) error {
|
||||
d.Time = time.Unix(src.(int64), 0)
|
||||
return nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func (d NullableDBInt) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
// Scan takes data from the database and modifies it for Go Types
|
||||
func (d *NullableDBInt) Scan(src interface{}) error {
|
||||
func (d *NullableDBInt) Scan(src any) error {
|
||||
var i int
|
||||
switch v := src.(type) {
|
||||
case int:
|
||||
|
@ -18,16 +18,19 @@ func (d NullableDBUint) Value() (driver.Value, error) {
|
||||
}
|
||||
// According to current database/sql docs, the sql has four builtin functions that
|
||||
// returns driver.Value, and the underlying types are `int64`, `float64`, `string` and `bool`
|
||||
// nolint: gosec
|
||||
return driver.Value(int64(d.Uint)), nil
|
||||
}
|
||||
|
||||
// Scan takes data from the database and modifies it for Go Types
|
||||
func (d *NullableDBUint) Scan(src interface{}) error {
|
||||
func (d *NullableDBUint) Scan(src any) error {
|
||||
var i uint
|
||||
switch v := src.(type) {
|
||||
case int:
|
||||
// nolint: gosec
|
||||
i = uint(v)
|
||||
case int64:
|
||||
// nolint: gosec
|
||||
i = uint(v)
|
||||
case float32:
|
||||
i = uint(v)
|
||||
@ -35,6 +38,7 @@ func (d *NullableDBUint) Scan(src interface{}) error {
|
||||
i = uint(v)
|
||||
case string:
|
||||
a, _ := strconv.Atoi(v)
|
||||
// nolint: gosec
|
||||
i = uint(a)
|
||||
}
|
||||
d.Uint = i
|
||||
|
@ -50,7 +50,7 @@ func TestNullableDBUint_Scan(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
input interface{}
|
||||
input any
|
||||
wantUint uint
|
||||
wantErr bool
|
||||
}{
|
||||
|
@ -9,18 +9,18 @@ import (
|
||||
|
||||
// JSONB can be anything
|
||||
type JSONB struct {
|
||||
Encoded string `json:"decoded"`
|
||||
Decoded interface{} `json:"encoded"`
|
||||
Encoded string `json:"decoded"`
|
||||
Decoded any `json:"encoded"`
|
||||
}
|
||||
|
||||
// Value encodes the type ready for the database
|
||||
func (j JSONB) Value() (driver.Value, error) {
|
||||
json, err := json.Marshal(j.Decoded)
|
||||
return driver.Value(string(json)), err
|
||||
jsn, err := json.Marshal(j.Decoded)
|
||||
return driver.Value(string(jsn)), err
|
||||
}
|
||||
|
||||
// Scan takes data from the database and modifies it for Go Types
|
||||
func (j *JSONB) Scan(src interface{}) error {
|
||||
func (j *JSONB) Scan(src any) error {
|
||||
var jsonb JSONB
|
||||
var srcString string
|
||||
switch v := src.(type) {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// TestJSONBValue tests the Value method of the JSONB type
|
||||
func TestJSONBValue(t *testing.T) {
|
||||
j := JSONB{
|
||||
Decoded: map[string]interface{}{
|
||||
Decoded: map[string]any{
|
||||
"name": "John",
|
||||
"age": 30,
|
||||
},
|
||||
@ -35,7 +35,7 @@ func TestJSONBScan(t *testing.T) {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expectedDecoded := map[string]interface{}{
|
||||
expectedDecoded := map[string]any{
|
||||
"name": "John",
|
||||
"age": 30,
|
||||
}
|
||||
@ -59,7 +59,7 @@ func TestJSONBUnmarshalJSON(t *testing.T) {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expectedDecoded := map[string]interface{}{
|
||||
expectedDecoded := map[string]any{
|
||||
"name": "John",
|
||||
"age": 30,
|
||||
}
|
||||
@ -76,7 +76,7 @@ func TestJSONBUnmarshalJSON(t *testing.T) {
|
||||
// TestJSONBMarshalJSON tests the MarshalJSON method of the JSONB type
|
||||
func TestJSONBMarshalJSON(t *testing.T) {
|
||||
j := JSONB{
|
||||
Decoded: map[string]interface{}{
|
||||
Decoded: map[string]any{
|
||||
"name": "John",
|
||||
"age": 30,
|
||||
},
|
||||
@ -113,7 +113,7 @@ func TestJSONBAsStringArray(t *testing.T) {
|
||||
}
|
||||
|
||||
// Helper function to compare JSON objects
|
||||
func jsonEqual(a, b interface{}) bool {
|
||||
func jsonEqual(a, b any) bool {
|
||||
aJSON, _ := json.Marshal(a)
|
||||
bJSON, _ := json.Marshal(b)
|
||||
return string(aJSON) == string(bJSON)
|
||||
|
@ -23,7 +23,7 @@ func (d NullableDBDate) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
// Scan takes data from the database and modifies it for Go Types
|
||||
func (d *NullableDBDate) Scan(src interface{}) error {
|
||||
func (d *NullableDBDate) Scan(src any) error {
|
||||
var tme time.Time
|
||||
if src != nil {
|
||||
tme = time.Unix(src.(int64), 0)
|
||||
|
Reference in New Issue
Block a user