esutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilenameToReader added in v0.1.4

func FilenameToReader(name string) (*bytes.Reader, error)

func Find

func Find(slice []string, val string) (int, bool)

https://golangcode.com/check-if-element-exists-in-slice/ Find takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.

func GetResponse added in v0.1.4

func GetResponse(r esRequest, c *elastic7.Client) (*esapi.Response, error)

func JSONToReader added in v0.1.4

func JSONToReader(intf interface{}) (*bytes.Reader, error)

Take json. Return a reader

func ParseBytes

func ParseBytes(b []byte, fmtExists bool, outputFmt string) (err error)

TODO - remove this in the future if not needed

// Check if the 'Format' field exists for a struct beneath a provided interface

func FormatExists(i interface{}) bool {
	return reflect.ValueOf(i).FieldByName("Format").IsValid()
}

Convert bytes into a desired output format

func RequestNew

func RequestNew(r esRequest, c *elastic7.Client) ([]byte, error)

Generic function used to execute requests and return bytes

func SetBool added in v0.1.4

func SetBool(s reflect.Value, field string, a bool) bool

Attempt to change the value of an arbitrary boolean type field Return whether the field exists and could be set

func SetFormat

func SetFormat(s reflect.Value, outputFmt string) bool

Attempt to change the 'Format' field of a struct if it exists. Return whether the field exists and could be set

func SetInt added in v0.1.4

func SetInt(s reflect.Value, field string, a int64) bool

Attempt to change the value of an arbitrary int64 type field Return whether the field exists and could be set

func SetString added in v0.1.4

func SetString(s reflect.Value, field string, a string) bool

Attempt to change the value of an arbitrary string type field Return whether the field exists and could be set

Types

This section is empty.

Jump to

Keyboard shortcuts

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