func TimeFromValue(
	v kv.Value, key string, defaultValue time.Time, opts Options,
) (time.Time, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res time.Time
	updateFn := func(i interface{}) { res = i.(time.Time) }
	if err := updateWithKV(
		getTime, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return time.Time{}, err
	}
	return res, nil
}
TimeFromValue gets a time.Time from kv.Value. If the value is nil, the
default value is returned.
package util
import (
	"errors"
	"fmt"
	"time"
	"github.com/m3db/m3cluster/generated/proto/commonpb"
	"github.com/m3db/m3cluster/kv"
	"github.com/m3db/m3x/log"
)
var (
	errNilStore = errors.New("kv store is nil")
)
func BoolFromValue(v kv.Value, key string, defaultValue bool, opts Options) (bool, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res bool
	updateFn := func(i interface{}) { res = i.(bool) }
	if err := updateWithKV(
		getBool, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return false, err
	}
	return res, nil
}
func Float64FromValue(v kv.Value, key string, defaultValue float64, opts Options) (float64, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res float64
	updateFn := func(i interface{}) { res = i.(float64) }
	if err := updateWithKV(
		getFloat64, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return 0, err
	}
	return res, nil
}
func Int64FromValue(v kv.Value, key string, defaultValue int64, opts Options) (int64, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res int64
	updateFn := func(i interface{}) { res = i.(int64) }
	if err := updateWithKV(
		getInt64, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return 0, err
	}
	return res, nil
}
func StringFromValue(v kv.Value, key string, defaultValue string, opts Options) (string, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res string
	updateFn := func(i interface{}) { res = i.(string) }
	if err := updateWithKV(
		getString, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return "", err
	}
	return res, nil
}
func StringArrayFromValue(
	v kv.Value, key string, defaultValue []string, opts Options,
) ([]string, error) {
	if opts == nil {
		opts = NewOptions()
	}
	var res []string
	updateFn := func(i interface{}) { res = i.([]string) }
	if err := updateWithKV(
		getStringArray, updateFn, opts.ValidateFn(), key, v, defaultValue, opts.Logger(),
	); err != nil {
		return nil, err
	}
	return res, nil
}