Description
Unlike many other programming lanugages, Go doesn't provide helper functions for slices in it's core. I felt like this was quite an essential feature and there weren't any libraries out there that would do this, so I made my own. The functions are the same as the in the Go's official "strings" package, but you can use them on slices.
go-slices alternatives and similar packages
Based on the "Go Tools" category.
Alternatively, view go-slices alternatives based on common mentions on social networks and blogs.
-
Go Interview Practice
Interactive Go Interview Platform - 30+ coding challenges with instant feedback, AI interview simulation, competitive leaderboards, and automated testing. From beginner to advanced levels with real-world scenarios. -
The Go Play Space
Advanced Go Playground frontend written in Go, with syntax highlighting, turtle graphics mode, and more -
Sonic
Sonic is a Go library for network and I/O programming that provides developers with a consistent asynchronous model, with a focus on achieving the lowest possible latency and jitter in Go. -
typex
[TOOL/CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations. -
Viney's go-cache
A flexible multi-layer Go caching library to deal with in-memory and shared cache by adopting Cache-Aside pattern. -
go-lock
go-lock is a lock library implementing read-write mutex and read-write trylock without starvation -
gothanks
GoThanks automatically stars Go's official repository and your go.mod github dependencies, providing a simple way to say thanks to the maintainers of the modules you use and the contributors of Go itself. -
goroutines
It is an efficient, flexible, and lightweight goroutine pool. It provides an easy way to deal with concurrent tasks with limited resource. -
PDF to Image Converter Using Golang
This project will help you to convert PDF file to IMAGE using golang. -
go-james
DISCONTINUED. James is your butler and helps you to create, build, debug, test and run your Go projects -
docs
DISCONTINUED. Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard -
Rate Limiter
A robust, thread-safe, and distributed rate limiter for Go, designed for high-throughput applications. -
go-sanitize
🛁 Lightweight Go library providing robust string sanitization and normalization utilities -
rescached
DISCONTINUED. [mirror] Resolver (DNS) cache daemon. See https://sr.ht/~shulhan/rescached [Moved to: https://github.com/shuLhan/rescached] -
modver
Compare two versions of a Go module to check the version-number change required (major, minor, or patchlevel), according to semver rules. -
Goenv
DISCONTINUED. 🐺 Manage Your Applications Go Environment. [Moved to: https://github.com/Clivern/Goenv] -
IP2Location.io Command Line
IP2Location.io command line to query IP geolocation data from IP2Location.io API -
channelize
A websocket framework to manage outbound streams. Allowing to have multiple channels per connection that includes public and private channels. -
IP2Location.io SDK
IP2Location.io Go SDK allows user to query for an enriched data set based on IP address and provides WHOIS lookup api that helps users to obtain domain information.
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of go-slices or a related project?
README
go-slices
Unlike many other programming languages, Go doesn't provide helper functions for slices in it's core. I felt like this was quite an essential feature and there weren't any libraries out there that would do this, so I made my own. The functions are the same as the in the Go's official "strings" package, but you can use them on slices.
How to install
Open your terminal and type:
go get github.com/merkur0/go-slices
Then, import this package in your .go file like this:
import (
"github.com/merkur0/go-slices"
)
And that's it!
Usage:
slices.FunctionName(parameters)
Example:
mySlice := []int{1, 2, 3}
slices.ContainsInt(mySlice, 3) // Returns "true"
List of functions:
Contains
Returns true if the slice contains the item and false if it doesn't. Example:
mySlice := []float32{1.1, 1.2, 1.3, 1.4, 1.5}
slices.ContainsFloat32(myArr, 1.2) // returns true
slices.ContainsFloat32(myArr, 2.3) // returns false
Count
Returns the number of instances of the item within the slice. Example:
mySlice := []int{1, 1, 1, 2, 1}
slices.CountInt(mySlice, 1) // returns 4
slices.CountInt(mySlice, 3) // returns 0
Delete
Returns a copy of the slice where the item with the index (second parameter) is deleted. Example:
mySlice := []int{1, 2, 3, 4, 5}
slices.DeleteInt(mySlice, 0) // returns [2, 3, 4, 5]
Index
Returns the index of the first instance of the second parameter in the slice, or -1 if item is not present in the slice. Example:
mySlice := []int{4, 1, 5}
slices.IndexInt(mySlice, 5) // returns 2
LastIndex
Returns the index of the last instance of the second parameter in the slice, or -1 if item is not present in the slice. Example:
mySlice := []int{1, 2, 1, 1, 4}
slices.LastIndexInt(mySlice, 1) // returns 3
Map
Returns a copy of the slice with all its items modified according to the mapping function. Example:
myFunc := func(number int) int {
return number * 2
}
mySlice := []int{1, 2, 3, 4}
slices.MapInt(mySlice, myFunc) // returns [2, 4, 6, 8]
Max
Returns the largest element in the slice. Example:
mySlice := []int{1, 2, 3, 4}
slices.MaxInt(mySlice) // returns 4
Min
Returns the smallest element in the slice. Example:
mySlice := []int{1, 2, 3, 4}
slices.MinInt(mySlice) // returns 1
Pop
Returns a copy of the slice with it's last item removed. Example:
mySlice := []int{1, 2, 3, 4}
slices.PopInt(mySlice) // returns [1, 2, 3]
Replace
Returns a copy of the slice where the first instance of the old item (second parameter) is replaced with the new item (third parameter). Example:
mySlice := []int{1, 1, 3, 5, 1}
slices.ReplaceInt(mySlice, 1, 0) // returns [0, 1, 3, 5, 1]
ReplaceAll
Returns a copy of the slice where every instance of the old item (second parameter) is replaced with the new item (third parameter) and returns the new slice. Example:
mySlice := []int{1, 1, 3, 5, 1}
slices.ReplaceAllInt(mySlice, 1, 0) // returns [0, 0, 3, 5, 1]
Shift
Returns a copy of the slice with it's first item removed. Example:
mySlice := []int{1, 2, 3}
slices.ShiftInt(mySlice) // returns [2, 3]