Skip to content

Commit

Permalink
Simplify code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
roblillack committed Mar 23, 2021
1 parent 836f56e commit c16eb73
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 142 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015–2020 Rob Lillack
Copyright (c) 2015–2021 Rob Lillack
Copyright (C) 2012 Rob Figueiredo
All Rights Reserved.

Expand Down
2 changes: 1 addition & 1 deletion binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func unbindSlice(output map[string]string, name string, val interface{}) {
func bindStruct(params *Params, name string, typ reflect.Type) reflect.Value {
result := reflect.New(typ).Elem()
fieldValues := make(map[string]reflect.Value)
for key, _ := range params.Values {
for key := range params.Values {
if !strings.HasPrefix(key, name+".") {
continue
}
Expand Down
12 changes: 6 additions & 6 deletions binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,28 @@ var unbinderTestCases = map[string]interface{}{
// Some of the unbinding results are not exactly what is in PARAMS, since it
// serializes implicit zero values explicitly.
var unbinderOverrideAnswers = map[string]map[string]string{
"arr": map[string]string{
"arr": {
"arr[0]": "1",
"arr[1]": "2",
"arr[2]": "0",
"arr[3]": "3",
},
"A": map[string]string{
"A": {
"A.ID": "123",
"A.Name": "rob",
"A.B.Extra": "",
},
"arrC": map[string]string{
"arrC": {
"arrC[0].ID": "5",
"arrC[0].Name": "rob",
"arrC[0].B.Extra": "foo",
"arrC[1].ID": "8",
"arrC[1].Name": "bill",
"arrC[1].B.Extra": "",
},
"m": map[string]string{"m[a]": "foo", "m[b]": "bar"},
"m2": map[string]string{"m2[1]": "foo", "m2[2]": "bar"},
"m3": map[string]string{"m3[a]": "1", "m3[b]": "2"},
"m": {"m[a]": "foo", "m[b]": "bar"},
"m2": {"m2[1]": "foo", "m2[2]": "bar"},
"m3": {"m3[a]": "1", "m3[b]": "2"},
}

func TestUnbinder(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

func TestCertificateCreation(t *testing.T) {
for org, domains := range map[string][]string{
"ACME Inc.": []string{"acme.com", "acme.biz"},
"Me": []string{"::1", "127.0.0.1"},
"ACME Inc.": {"acme.com", "acme.biz"},
"Me": {"::1", "127.0.0.1"},
} {
keypair, err := createCertificate(org, strings.Join(domains, ", "))
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions fakeapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ func (c MyStatic) Serve(prefix, filepath string) Result {
func startFakeBookingApp() {
RegisterController((*Hotels)(nil),
[]*MethodType{
&MethodType{
{
Name: "Index",
},
&MethodType{
{
Name: "Boom",
},
&MethodType{
{
Name: "Show",
Args: []*MethodArg{
{"id", reflect.TypeOf((*int)(nil))},
},
},
&MethodType{
{
Name: "Book",
Args: []*MethodArg{
{"id", reflect.TypeOf((*int)(nil))},
Expand All @@ -86,11 +86,11 @@ func startFakeBookingApp() {

RegisterController((*Static)(nil),
[]*MethodType{
&MethodType{
{
Name: "Serve",
Args: []*MethodArg{
&MethodArg{Name: "prefix", Type: reflect.TypeOf((*string)(nil))},
&MethodArg{Name: "filepath", Type: reflect.TypeOf((*string)(nil))},
{Name: "prefix", Type: reflect.TypeOf((*string)(nil))},
{Name: "filepath", Type: reflect.TypeOf((*string)(nil))},
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
func MessageLanguages() []string {
languages := make([]string, len(messages))
i := 0
for language, _ := range messages {
for language := range messages {
languages[i] = language
i++
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pathtree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func BenchmarkTree100(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N/len(queries); i++ {
for k, _ := range queries {
for k := range queries {
n.Find(k)
}
}
Expand Down
Loading

0 comments on commit c16eb73

Please sign in to comment.