mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
Apply project wide go fmt
This commit is contained in:
@@ -83,12 +83,12 @@ func Dictionary(values ...interface{}) (map[string]interface{}, error) {
|
||||
return nil, errors.New("invalid dict call")
|
||||
}
|
||||
dict := make(map[string]interface{}, len(values)/2)
|
||||
for i := 0; i < len(values); i+=2 {
|
||||
for i := 0; i < len(values); i += 2 {
|
||||
key, ok := values[i].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("dict keys must be strings")
|
||||
}
|
||||
dict[key] = values[i+1]
|
||||
dict[key] = values[i+1]
|
||||
}
|
||||
return dict, nil
|
||||
}
|
||||
|
@@ -326,18 +326,18 @@ func TestAfter(t *testing.T) {
|
||||
|
||||
func TestDictionary(t *testing.T) {
|
||||
for i, this := range []struct {
|
||||
v1 []interface{}
|
||||
expecterr bool
|
||||
expectedValue map[string] interface{}
|
||||
v1 []interface{}
|
||||
expecterr bool
|
||||
expectedValue map[string]interface{}
|
||||
}{
|
||||
{[]interface{}{"a", "b"}, false, map[string]interface{}{"a":"b"}},
|
||||
{[]interface{}{5, "b"}, true,nil},
|
||||
{[]interface{}{"a", 12,"b",[]int{4}}, false,map[string]interface{}{"a":12,"b":[]int{4}}},
|
||||
{[]interface{}{"a", "b", "c"}, true,nil},
|
||||
{[]interface{}{"a", "b"}, false, map[string]interface{}{"a": "b"}},
|
||||
{[]interface{}{5, "b"}, true, nil},
|
||||
{[]interface{}{"a", 12, "b", []int{4}}, false, map[string]interface{}{"a": 12, "b": []int{4}}},
|
||||
{[]interface{}{"a", "b", "c"}, true, nil},
|
||||
} {
|
||||
r,e := Dictionary(this.v1...)
|
||||
r, e := Dictionary(this.v1...)
|
||||
|
||||
if (this.expecterr && e==nil) || (!this.expecterr && e!=nil) {
|
||||
if (this.expecterr && e == nil) || (!this.expecterr && e != nil) {
|
||||
t.Errorf("[%d] got an unexpected error", i, e, this.expecterr)
|
||||
} else if !this.expecterr {
|
||||
if !reflect.DeepEqual(r, this.expectedValue) {
|
||||
@@ -347,7 +347,6 @@ func TestDictionary(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestIn(t *testing.T) {
|
||||
for i, this := range []struct {
|
||||
v1 interface{}
|
||||
|
Reference in New Issue
Block a user