Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Jun 2, 2024
1 parent 6b1f8ee commit a413b73
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions openapi/internal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,27 @@ type TypeUsageCounter map[string]int

// Increase increases the usage of an element
func (tuc *TypeUsageCounter) Increase(name string) {
counter, _ := (*tuc)[name]
(*tuc)[name] = counter + 1
if counter, ok := (*tuc)[name]; ok {
(*tuc)[name] = counter + 1
} else {
(*tuc)[name] = 1
}
}

// Decrease decreases the usage of an element
func (tuc *TypeUsageCounter) Decrease(name string) {
counter, _ := (*tuc)[name]
if counter > 0 {
if counter, ok := (*tuc)[name]; ok && counter > 1 {
(*tuc)[name] = counter - 1
} else {
(*tuc)[name] = 0
}
}

// Get returns the usage count of the input name
func (tuc *TypeUsageCounter) Get(name string) int {
counter, _ := (*tuc)[name]
counter, ok := (*tuc)[name]
if !ok {
return 0
}
return counter
}

0 comments on commit a413b73

Please sign in to comment.