Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ramalho/strset
A full-featured set type for string elements in Go
https://github.com/ramalho/strset
go golang golang-examples golang-package sets testify
Last synced: about 1 month ago
JSON representation
A full-featured set type for string elements in Go
- Host: GitHub
- URL: https://github.com/ramalho/strset
- Owner: ramalho
- License: bsd-3-clause
- Created: 2018-04-03T20:43:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T13:05:32.000Z (about 6 years ago)
- Last Synced: 2024-09-29T21:21:30.450Z (about 1 month ago)
- Topics: go, golang, golang-examples, golang-package, sets, testify
- Language: Go
- Size: 26.4 KB
- Stars: 21
- Watchers: 4
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strset
[![GoDoc](https://godoc.org/github.com/standupdev/strset?status.svg)](https://godoc.org/github.com/standupdev/strset)
Full-featured Go `Set` type for `string` elements.
```golang
func Example() {
s1 := Make("red", "green", "blue", "yellow")
s2 := MakeFromText("yellow green white")
fmt.Println(s1.Intersection(s2))
// Output: Set{green yellow}
}
```Some features of the `strset.Set` type:
* `Make` builds a set from zero or more strings (or `[]string...`).
* `MakeFromText` builds a set from a single string with elements separated by whitespace.
* `String` method returns elements in ascending order.
* Methods returning new sets: intersection, union, difference, symmetric difference.
* Methods updating receiver in-place for each operation above.
* `Pop` method to retrieve and delete one unspecified element.
* Need an immutable set? Just remove `updaters.go` from the build.
* 100% test coverage.
* Not thread-safe.Happy hacking!