Cantrips is a collection of useful functions in the Go Programming Language
NOTE
/ ˈkɑn trɪp / noun
chiefly Scotland: a magic spell; trick by sorcery.chiefly British: hocus-pocus.
Cantrips are small (magical) utility functions to achieve common tasks in Go.
The name was inspired by Svelte 5's Runes and Baldur's Gate 3.
For example the Pop() function will remove the last element from a slice and
return that element.
package main
import (
"fmt"
"github.com/banaaron/cantrips"
)
func main() {
names := []string{"aaron", "chris", "drew"}
n := cantrips.Pop(&names)
fmt.Println(n) // "drew"
fmt.Println(names) // ["aaron", "chris"]
// you can provide an index to remove an element at a specific index
p := cantrips.Pop(&names, 1)
fmt.Println(p) // "chris"
fmt.Println(names) // ["aaron"]
}