Skip to content

Instantly share code, notes, and snippets.

@wjx0912
Created May 2, 2018 12:27
Show Gist options
  • Select an option

  • Save wjx0912/3ec002f7d7f53bbe20cd23794927b32f to your computer and use it in GitHub Desktop.

Select an option

Save wjx0912/3ec002f7d7f53bbe20cd23794927b32f to your computer and use it in GitHub Desktop.
golang split string
https://medium.com/@mlowicki/strings-fieldsfunc-vs-strings-split-96c667912f78
fmt.Printf("%#v\n", strings.Split("/a/b/c", "/"))
// []string{"", "a", "b", "c"}
fmt.Printf("%#v\n", strings.FieldsFunc("/a/b/c", func(c rune) bool { return c == ‘/’ }))
// []string{"a", "b", "c"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment