diff --git a/_examples/auth/goth/main.go b/_examples/auth/goth/main.go index 3b4111a9..9fc4f4b1 100644 --- a/_examples/auth/goth/main.go +++ b/_examples/auth/goth/main.go @@ -301,45 +301,46 @@ func main() { goth.UseProviders(openidConnect) } - m := make(map[string]string) - m["amazon"] = "Amazon" - m["bitbucket"] = "Bitbucket" - m["box"] = "Box" - m["dailymotion"] = "Dailymotion" - m["deezer"] = "Deezer" - m["digitalocean"] = "Digital Ocean" - m["discord"] = "Discord" - m["dropbox"] = "Dropbox" - m["facebook"] = "Facebook" - m["fitbit"] = "Fitbit" - m["github"] = "Github" - m["gitlab"] = "Gitlab" - m["soundcloud"] = "SoundCloud" - m["spotify"] = "Spotify" - m["steam"] = "Steam" - m["stripe"] = "Stripe" - m["twitch"] = "Twitch" - m["uber"] = "Uber" - m["wepay"] = "Wepay" - m["yahoo"] = "Yahoo" - m["yammer"] = "Yammer" - m["gplus"] = "Google Plus" - m["heroku"] = "Heroku" - m["instagram"] = "Instagram" - m["intercom"] = "Intercom" - m["lastfm"] = "Last FM" - m["linkedin"] = "Linkedin" - m["onedrive"] = "Onedrive" - m["paypal"] = "Paypal" - m["twitter"] = "Twitter" - m["salesforce"] = "Salesforce" - m["slack"] = "Slack" - m["meetup"] = "Meetup.com" - m["auth0"] = "Auth0" - m["openid-connect"] = "OpenID Connect" - m["xero"] = "Xero" + m := map[string]string{ + "amazon": "Amazon", + "bitbucket": "Bitbucket", + "box": "Box", + "dailymotion": "Dailymotion", + "deezer": "Deezer", + "digitalocean": "Digital Ocean", + "discord": "Discord", + "dropbox": "Dropbox", + "facebook": "Facebook", + "fitbit": "Fitbit", + "github": "Github", + "gitlab": "Gitlab", + "soundcloud": "SoundCloud", + "spotify": "Spotify", + "steam": "Steam", + "stripe": "Stripe", + "twitch": "Twitch", + "uber": "Uber", + "wepay": "Wepay", + "yahoo": "Yahoo", + "yammer": "Yammer", + "gplus": "Google Plus", + "heroku": "Heroku", + "instagram": "Instagram", + "intercom": "Intercom", + "lastfm": "Last FM", + "linkedin": "Linkedin", + "onedrive": "Onedrive", + "paypal": "Paypal", + "twitter": "Twitter", + "salesforce": "Salesforce", + "slack": "Slack", + "meetup": "Meetup.com", + "auth0": "Auth0", + "openid-connect": "OpenID Connect", + "xero": "Xero", + } - var keys []string + keys := make([]string, 0, len(m)) for k := range m { keys = append(keys, k) } diff --git a/_examples/mvc/vuejs-todo-mvc/src/todo/service.go b/_examples/mvc/vuejs-todo-mvc/src/todo/service.go index d9af2854..6f40ce23 100644 --- a/_examples/mvc/vuejs-todo-mvc/src/todo/service.go +++ b/_examples/mvc/vuejs-todo-mvc/src/todo/service.go @@ -18,7 +18,7 @@ type MemoryService struct { func NewMemoryService() *MemoryService { return &MemoryService{ - items: make(map[string][]Item, 0), + items: make(map[string][]Item), } } diff --git a/context/context.go b/context/context.go index f758d323..85196cf6 100644 --- a/context/context.go +++ b/context/context.go @@ -3030,11 +3030,11 @@ func (ctx *Context) ReadMultipartRelated() (MultipartRelated, error) { return result, nil } -func distinctStrings(values []string) (result []string) { - seen := make(map[string]struct{}) +func distinctStrings(values []string) []string { + seen := make(map[string]struct{}, len(values)) + result := make([]string, 0, len(values)) - for v := range values { - val := values[v] + for _, val := range values { if _, ok := seen[val]; !ok { seen[val] = struct{}{} result = append(result, val)