Skip to content

Conversation

cuishuang
Copy link
Contributor

@cuishuang cuishuang commented Feb 25, 2023

There are many scenarios where it is necessary to obtain the difference of two slices. At present, the more common method is to create a new utils package in the project and write the method implementation in it. Now that the Go standard library has a new slices package, it is recommended to add an API:

Update golang/go#58730

Signed-off-by: cui fliter <imcusg@gmail.com>
@gopherbot
Copy link
Contributor

This PR (HEAD: 33ca1be) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/exp/+/471277 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

if s2len == 0 {
return s1
}
s2Map := make(map[E]bool, s2len)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use map[E]struct{}?

Suggested change
s2Map := make(map[E]bool, s2len)
s2Map := make(map[E]struct{}, s2len)

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

Successfully merging this pull request may close these issues.

3 participants