Skip to content

Commit

Permalink
code style: fixed slice initialization in mite package
Browse files Browse the repository at this point in the history
A nil slice is for the purpose of append a slice even though it points
to nothing. See: https://blog.golang.org/slices
  • Loading branch information
phiros committed Apr 4, 2019
1 parent ee67849 commit 9852c3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mite/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func (r *projectResponse) ToProject() *Project {
}

func (a *miteApi) Projects() ([]*Project, error) {
prs := []projectResponse{}
var prs []projectResponse
err := a.get("projects.json", &prs)
if err != nil {
return nil, err
}

projects := []*Project{}
var projects []*Project
for _, pr := range prs {
projects = append(projects, pr.ToProject())
}
Expand Down
4 changes: 2 additions & 2 deletions mite/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func (r *serviceResponse) ToService() *Service {
}

func (a *miteApi) Services() ([]*Service, error) {
srs := []serviceResponse{}
var srs []serviceResponse
err := a.get("services.json", &srs)
if err != nil {
return nil, err
}

services := []*Service{}
var services []*Service
for _, sr := range srs {
services = append(services, sr.ToService())
}
Expand Down
4 changes: 2 additions & 2 deletions mite/time_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ func (r *timeEntryResponse) ToTimeEntry() *TimeEntry {
}

func (a *miteApi) TimeEntries(query *TimeEntryQuery) ([]*TimeEntry, error) {
ter := []timeEntryResponse{}
var ter []timeEntryResponse
err := a.getParametrized("time_entries.json", query.toValues(), &ter)
if err != nil {
return nil, err
}

timeEntries := []*TimeEntry{}
var timeEntries []*TimeEntry
for _, te := range ter {
timeEntries = append(timeEntries, te.ToTimeEntry())
}
Expand Down

0 comments on commit 9852c3e

Please sign in to comment.