goin

package module
v0.0.0-...-c177f62 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: MIT Imports: 2 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	// contains filtered or unexported fields
}

A Item holds a data to be checked in array, slice or map.

func Value

func Value(x interface{}) *Item

Value returns a new Value set data to x.

func (*Item) In

func (i *Item) In(arr interface{}) (bool, error)

In reports whether Value can be found in array/slice arr.

func (*Item) InKey

func (i *Item) InKey(arr interface{}) (bool, error)

InKey reports whether Value can be found as key of map arr.

Jump to

Keyboard shortcuts

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