chunks

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2023 License: GPL-3.0 Imports: 0 Imported by: 0

README

Chunks Go Report Card

A Go (golang) slice chunking library

Installation

As a library

go get github.com/brettcodling/chunks

Usage

package main

import github.com/brettcodling/chunks"

type Test struct {
}

func main() {
  // You can chunk slices into any size you like
  slice := []string{"1", "2", "3"}
  chunkedSlice := chunks.Chunk(slice, 1)
  // len(chunkedSlice) == 3
  
  // You can chunk slices of custom types
  chunks.Chunk([]Test{
			{},
			{},
			{},
		}, 1)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T any](s []T, size int) [][]T

Chunk will split a slice up into chunks of a given size

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL