Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why use copy instead of loop #561

Closed
Jerry-yz opened this issue Jul 13, 2024 · 1 comment
Closed

why use copy instead of loop #561

Jerry-yz opened this issue Jul 13, 2024 · 1 comment

Comments

@Jerry-yz
Copy link

why not use copy(result, c.webServices)
loop
func (c *Container) RegisteredWebServices() []*WebService {
c.webServicesLock.RLock()
defer c.webServicesLock.RUnlock()
result := make([]*WebService, len(c.webServices))
for ix := range c.webServices {
result[ix] = c.webServices[ix]
}
return result
}

@emicklei
Copy link
Owner

there was no particular reason for not using copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants