github.com/vbsw/contains

"contains" function for slices


Keywords
contains, go, golang, slice, slices
License
BSL-1.0
Install
go get github.com/vbsw/contains

Documentation

Contains Package

GoDoc Go Report Card Stability: Maintenance

About

This package provides the function "contains" for slices of basic types. It is published on https://github.com/vbsw/contains.

Copyright

Copyright 2018, Vitali Baumtrok (vbsw@mailbox.org).

Contains Package is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

Contains Package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Example

Source Code:

package main

import (
	"fmt"
	"github.com/vbsw/contains"
)

func main() {
	names := []String{"Alice","Bob","Claire","Dave"}

	if contains.String(names,"Bob") {
		fmt.Println("Contains the name Bob.")
	}
}

Output:

Contains the name Bob.

Using Git

Clone the master branch and all refs of this project:

$ git clone https://github.com/vbsw/contains.git

See all tags:

$ git tag -l

See local and remote branches:

$ git branch -a

Check out other branches than master, for example the development branch:

$ git branch development origin/development
$ git checkout development

See tracked remote branches:

$ git branch -vv

Update all tracked branches and all refs:

$ git fetch

References