Skip to content

Commit

Permalink
pangpanglabs#36 Allow same Tag for API groups
Browse files Browse the repository at this point in the history
  • Loading branch information
elvinchan committed Feb 10, 2020
1 parent 498f237 commit de47849
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: go

go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- tip

before_install:
Expand Down
12 changes: 0 additions & 12 deletions wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,6 @@ func (r *Root) Group(name, prefix string, m ...echo.MiddlewareFunc) ApiGroup {
defs: r.defs,
},
}
var counter int
LoopTags:
for _, t := range r.groups {
if t.tag.Name == name {
if counter > 0 {
name = name[:len(name)-2]
}
counter++
name += "_" + strconv.Itoa(counter)
goto LoopTags
}
}
group.tag = Tag{Name: name}
r.groups = append(r.groups, group)
return &r.groups[len(r.groups)-1]
Expand Down
4 changes: 2 additions & 2 deletions wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func TestGroup(t *testing.T) {

t.Run("Repeat name", func(t *testing.T) {
ga := r.Group("Users", "users")
assert.Equal(t, ga.(*group).tag.Name, "Users_1")
assert.Equal(t, ga.(*group).tag.Name, "Users")

gb := r.Group("Users", "users")
assert.Equal(t, gb.(*group).tag.Name, "Users_2")
assert.Equal(t, gb.(*group).tag.Name, "Users")
})
}

Expand Down

0 comments on commit de47849

Please sign in to comment.