s1s1ty / goin

`in` operator for go

Home Page:https://godoc.org/github.com/s1s1ty/goin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goin

Go Report Card Build Status license GoDoc

goin Evaluates to true if it finds a variable in the specified sequence and false otherwise.

  • goin package is built inspired by python in operator

Installation and Usage

Install the package with:

go get github.com/s1s1ty/goin

Import it with:

import "github.com/s1s1ty/goin"

Quick Start

func main() {
	ar := []int{1, 2, 4, 7, 8, 3}
	found, _ := goin.Value(7).In(ar)
	fmt.Println(found) // true

	seq := []float64{1.11, 3.20, 5.89, 2.90}
	found, _ = goin.Value(2.9).In(seq)
	fmt.Println(found) // true

	dict := map[string]string{"name": "shaon", "id": "110"}
	found, _ = goin.Value("fullname").InKey(dict)
	fmt.Println(found) // false
}

Available Methods

  • In(arr interface{})
  • InKey(arr interface{})

License

Licenced under MIT Licence
Any Suggestions and Bug Report will be gladly appreciated.

About

`in` operator for go

https://godoc.org/github.com/s1s1ty/goin

License:MIT License


Languages

Language:Go 100.0%