stringset

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package stringset helps with common set operations on strings.

This is inspired by https://github.com/uber/kraken/blob/master/utils/stringset/stringset.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[string]struct{}

Set is a nifty little wrapper for common set operations on a map. Because it is equivalent to a map, make/range/len will still work with Set.

func New

func New(xs ...string) Set

New creates a new Set with xs.

func (Set) Add

func (s Set) Add(x string)

Add adds x to s.

func (Set) Has

func (s Set) Has(x string) bool

Has returns true if x is in s.

func (Set) Remove

func (s Set) Remove(x string)

Remove removes x from s.

func (Set) ToSlice

func (s Set) ToSlice() []string

ToSlice converts s to a slice.

Jump to

Keyboard shortcuts

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