
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
github.com/wernerstrydom/go-collections
This is a collection of data structures and algorithms implemented in Go. While one can use the standard library to implement these data structures, this library provides a more convenient and easy to use interface. There are collections that are safe for concurrent use and collections that are not.
This library doesn't import any other libraries, so it can be used in any project without worrying about dependency conflicts.
go get github.com/wernerstrydom/go-collections
The following is an example of how to use the list collection. The concurrent list is used in this example, but the same methods are available for the non-concurrent list. The only difference is that the non-concurrent list is not safe for concurrent use.
package main
import (
"github.com/wernerstrydom/go-collections/concurrent"
"fmt"
)
func main() {
// write an example showing all the uses of a list
list := concurrent.NewList[string]()
_ = list.Add("a")
_ = list.Add("b")
_ = list.Add("c")
fmt.Println("After Add")
for i := 0; i < list.Len(); i++ {
item, _ := list.Get(i)
fmt.Println(item)
}
fmt.Println("Index of b")
index := list.IndexOf("b")
fmt.Println(index)
fmt.Println("Insert d at index 1")
_ = list.Insert(1, "d")
for i := 0; i < list.Len(); i++ {
item, _ := list.Get(i)
fmt.Println(item)
}
fmt.Println("Remove b")
_ = list.Remove("b")
for i := 0; i < list.Len(); i++ {
item, _ := list.Get(i)
fmt.Println(item)
}
fmt.Println("Remove at index 1")
_ = list.RemoveAt(1)
for i := 0; i < list.Len(); i++ {
item, _ := list.Get(i)
fmt.Println(item)
}
fmt.Println("Clear")
list.Clear()
fmt.Println(list.Len())
// Output:
// After Add
// a
// b
// c
// Index of b
// 1
// Insert d at index 1
// a
// d
// b
// c
// Remove b
// a
// d
// c
// Remove at index 1
// a
// c
// Clear
// 0
}
The following collections are available:
No algorithms are currently implemented.
This project is licensed under the MIT License - see the LICENSE file for details.
The library was inspired by the .NET Collections.
Please submit a pull request if you would like to contribute to this project.
Contact me at hello@wernerstrydom.com.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.