From 73af7c02fb062623c31adc1c27c4bb0eff7d83b0 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Fri, 5 Mar 2021 12:40:56 -0500 Subject: [PATCH] run golangcli-lint Signed-off-by: Rui Yang --- connector/cf/cf.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/connector/cf/cf.go b/connector/cf/cf.go index ba0b09d1fb..4d839ff63a 100644 --- a/connector/cf/cf.go +++ b/connector/cf/cf.go @@ -192,38 +192,36 @@ func (c *cfConnector) LoginURL(scopes connector.Scopes, callbackURL, state strin } func fetchRoleSpaces(baseURL, path, role string, client *http.Client) ([]Space, error) { - var spaces []Space - resources, err := fetchResources(baseURL, path, client) if err != nil { return nil, fmt.Errorf("failed to fetch resources: %v", err) } - for _, resource := range resources { - spaces = append(spaces, Space{ + spaces := make([]Space, len(resources)) + for i, resource := range resources { + spaces[i] = Space{ Name: resource.Entity.Name, GUID: resource.Metadata.GUID, OrgGUID: resource.Entity.OrganizationGUID, Role: role, - }) + } } return spaces, nil } func fetchOrgs(baseURL, path string, client *http.Client) ([]Org, error) { - var orgs []Org - resources, err := fetchResources(baseURL, path, client) if err != nil { return nil, fmt.Errorf("failed to fetch resources: %v", err) } - for _, resource := range resources { - orgs = append(orgs, Org{ + orgs := make([]Org, len(resources)) + for i, resource := range resources { + orgs[i] = Org{ Name: resource.Entity.Name, GUID: resource.Metadata.GUID, - }) + } } return orgs, nil @@ -293,7 +291,7 @@ func getGroupsClaims(orgs []Org, spaces []Space) []string { } } - var groups []string + groups := make([]string, 0, len(groupsClaims)) for group := range groupsClaims { groups = append(groups, group) }