util

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 7 Imported by: 1

README

util

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomId

func GenerateRandomId() string

func IntInSlice

func IntInSlice(n int, ns []int) bool

func Keys

func Keys(m map[int][]string) []int

func Max

func Max(x, y int32) int32

func MergeIntSlices

func MergeIntSlices(a, b []int) []int

func MsgPackMarshal

func MsgPackMarshal(v interface{}) ([]byte, error)

func MsgPackUnMarshal

func MsgPackUnMarshal(data []byte, v interface{}) error

func ReadJsonBody

func ReadJsonBody(body io.ReadCloser, out interface{}) (err error)

read from ReadCloser and unmarshal to out; `out` should be of POINTER type

func StingInSlice

func StingInSlice(s string, ss []string) bool

func WithLock

func WithLock(lock sync.Locker, f func())

Types

type Item

type Item interface {
	Weight() int32
	Value() int32
}

func PickItems

func PickItems(items []Item, capacity int32) (value int32, picked []Item)

Pick items to maximize value, within constrain of weight capacity

Jump to

Keyboard shortcuts

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