slices

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 1 Imported by: 0

README

Slices Examples

Remove duplicates

  • From a []string
package main

import (
  "fmt"
  
  "github.com/D3Ext/maldev/slices"
)

func main(){
  unique := slices.RemoveDuplicatesStr([]string{"first", "second", "third", "first", "third"})
  fmt.Println(unique)
}
  • From a []int
package main

import (
  "fmt"
  
  "github.com/D3Ext/maldev/slices"
)

func main(){
  unique := slices.RemoveDuplicatesInt([]int{1, 2, 3, 1, 3})
  fmt.Println(unique)
}

Check if slice contains

  • Strings
package main

import (
  "fmt"
  
  "github.com/D3Ext/maldev/slices"
)

func main(){
  check := slices.StringSliceContains([]string{"first", "second", "third", "first", "third"}, "second")
  fmt.Println(check)
}
  • Ints
package main

import (
  "fmt"
  
  "github.com/D3Ext/maldev/slices"
)

func main(){
  check := slices.IntSliceContains([]int{1, 2, 3, 1, 3}, 2)
  fmt.Println(check)
}
  • Strings (insensitive)
package main

import (
  "fmt"
  
  "github.com/D3Ext/maldev/slices"
)

func main(){
  check := slices.SliceContainsInsensitive([]string{"fiRSt", "seCoNd", "tHirD", "FirSt", "ThiRd"}, "second")
  fmt.Println(check)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntSliceContains

func IntSliceContains(src []int, int_to_check int) bool

func RemoveDuplicatesInt

func RemoveDuplicatesInt(intslice []int) []int

func RemoveDuplicatesStr

func RemoveDuplicatesStr(strslice []string) []string

func SliceContainsInsensitive

func SliceContainsInsensitive(src []string, str_to_check string) bool

func StringSliceContains

func StringSliceContains(src []string, str_to_check string) bool

func ToLowercase added in v0.1.2

func ToLowercase(src []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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