Project structure refactor:

- Change package name general_server to gateway
- Changing the structure of directories and packages
- Adding vendor to the project
This commit is contained in:
2025-07-28 20:16:40 +03:00
parent 19b699d92b
commit ec94df5f4a
786 changed files with 357010 additions and 357 deletions

15
vendor/github.com/spf13/cast/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.go]
indent_style = tab
[{*.yml,*.yaml}]
indent_size = 2

25
vendor/github.com/spf13/cast/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,25 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.bench

39
vendor/github.com/spf13/cast/.golangci.yaml generated vendored Normal file
View File

@@ -0,0 +1,39 @@
version: "2"
run:
timeout: 10m
linters:
enable:
- errcheck
- govet
- ineffassign
- misspell
- nolintlint
# - revive
- unused
disable:
- staticcheck
settings:
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
formatters:
enable:
- gci
- gofmt
# - gofumpt
- goimports
# - golines
settings:
gci:
sections:
- standard
- default
- localmodule

21
vendor/github.com/spf13/cast/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Steve Francia
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
vendor/github.com/spf13/cast/Makefile generated vendored Normal file
View File

@@ -0,0 +1,40 @@
GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2)
.PHONY: check fmt lint test test-race vet test-cover-html help
.DEFAULT_GOAL := help
check: test-race fmt vet lint ## Run tests and linters
test: ## Run tests
go test ./...
test-race: ## Run tests with race detector
go test -race ./...
fmt: ## Run gofmt linter
ifeq "$(GOVERSION)" "12"
@for d in `go list` ; do \
if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \
echo "^ improperly formatted go files" && echo && exit 1; \
fi \
done
endif
lint: ## Run golint linter
@for d in `go list` ; do \
if [ "`golint $$d | tee /dev/stderr`" ]; then \
echo "^ golint errors!" && echo && exit 1; \
fi \
done
vet: ## Run go vet linter
@if [ "`go vet | tee /dev/stderr`" ]; then \
echo "^ go vet errors!" && echo && exit 1; \
fi
test-cover-html: ## Generate test coverage report
go test -coverprofile=coverage.out -covermode=count
go tool cover -func=coverage.out
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

79
vendor/github.com/spf13/cast/README.md generated vendored Normal file
View File

@@ -0,0 +1,79 @@
# cast
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spf13/cast/ci.yaml?style=flat-square)](https://github.com/spf13/cast/actions/workflows/ci.yaml)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/mod/github.com/spf13/cast)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/spf13/cast?style=flat-square&color=61CFDD)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/spf13/cast/badge?style=flat-square)](https://deps.dev/go/github.com%252Fspf13%252Fcast)
Easy and safe casting from one type to another in Go
Dont Panic! ... Cast
## What is Cast?
Cast is a library to convert between different go types in a consistent and easy way.
Cast provides simple functions to easily convert a number to a string, an
interface into a bool, etc. Cast does this intelligently when an obvious
conversion is possible. It doesnt make any attempts to guess what you meant,
for example you can only convert a string to an int when it is a string
representation of an int such as “8”. Cast was developed for use in
[Hugo](https://gohugo.io), a website engine which uses YAML, TOML or JSON
for meta data.
## Why use Cast?
When working with dynamic data in Go you often need to cast or convert the data
from one type into another. Cast goes beyond just using type assertion (though
it uses that when possible) to provide a very straightforward and convenient
library.
If you are working with interfaces to handle things like dynamic content
youll need an easy way to convert an interface into a given type. This
is the library for you.
If you are taking in data from YAML, TOML or JSON or other formats which lack
full types, then Cast is the library for you.
## Usage
Cast provides a handful of To_____ methods. These methods will always return
the desired type. **If input is provided that will not convert to that type, the
0 or nil value for that type will be returned**.
Cast also provides identical methods To_____E. These return the same result as
the To_____ methods, plus an additional error which tells you if it successfully
converted. Using these methods you can tell the difference between when the
input matched the zero value or when the conversion failed and the zero value
was returned.
The following examples are merely a sample of what is available. Please review
the code for a complete set.
### Example ToString:
cast.ToString("mayonegg") // "mayonegg"
cast.ToString(8) // "8"
cast.ToString(8.31) // "8.31"
cast.ToString([]byte("one time")) // "one time"
cast.ToString(nil) // ""
var foo interface{} = "one more time"
cast.ToString(foo) // "one more time"
### Example ToInt:
cast.ToInt(8) // 8
cast.ToInt(8.31) // 8
cast.ToInt("8") // 8
cast.ToInt(true) // 1
cast.ToInt(false) // 0
var eight interface{} = 8
cast.ToInt(eight) // 8
cast.ToInt(nil) // 0
## License
The project is licensed under the [MIT License](LICENSE).

69
vendor/github.com/spf13/cast/alias.go generated vendored Normal file
View File

@@ -0,0 +1,69 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"reflect"
"slices"
)
var kindNames = []string{
reflect.String: "string",
reflect.Bool: "bool",
reflect.Int: "int",
reflect.Int8: "int8",
reflect.Int16: "int16",
reflect.Int32: "int32",
reflect.Int64: "int64",
reflect.Uint: "uint",
reflect.Uint8: "uint8",
reflect.Uint16: "uint16",
reflect.Uint32: "uint32",
reflect.Uint64: "uint64",
reflect.Float32: "float32",
reflect.Float64: "float64",
}
var kinds = map[reflect.Kind]func(reflect.Value) any{
reflect.String: func(v reflect.Value) any { return v.String() },
reflect.Bool: func(v reflect.Value) any { return v.Bool() },
reflect.Int: func(v reflect.Value) any { return int(v.Int()) },
reflect.Int8: func(v reflect.Value) any { return int8(v.Int()) },
reflect.Int16: func(v reflect.Value) any { return int16(v.Int()) },
reflect.Int32: func(v reflect.Value) any { return int32(v.Int()) },
reflect.Int64: func(v reflect.Value) any { return v.Int() },
reflect.Uint: func(v reflect.Value) any { return uint(v.Uint()) },
reflect.Uint8: func(v reflect.Value) any { return uint8(v.Uint()) },
reflect.Uint16: func(v reflect.Value) any { return uint16(v.Uint()) },
reflect.Uint32: func(v reflect.Value) any { return uint32(v.Uint()) },
reflect.Uint64: func(v reflect.Value) any { return v.Uint() },
reflect.Float32: func(v reflect.Value) any { return float32(v.Float()) },
reflect.Float64: func(v reflect.Value) any { return v.Float() },
}
// resolveAlias attempts to resolve a named type to its underlying basic type (if possible).
//
// Pointers are expected to be indirected by this point.
func resolveAlias(i any) (any, bool) {
if i == nil {
return nil, false
}
t := reflect.TypeOf(i)
// Not a named type
if t.Name() == "" || slices.Contains(kindNames, t.Name()) {
return i, false
}
resolve, ok := kinds[t.Kind()]
if !ok { // Not a supported kind
return i, false
}
v := reflect.ValueOf(i)
return resolve(v), true
}

131
vendor/github.com/spf13/cast/basic.go generated vendored Normal file
View File

@@ -0,0 +1,131 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"encoding/json"
"fmt"
"html/template"
"strconv"
"time"
)
// ToBoolE casts any value to a bool type.
func ToBoolE(i any) (bool, error) {
i, _ = indirect(i)
switch b := i.(type) {
case bool:
return b, nil
case nil:
return false, nil
case int:
return b != 0, nil
case int8:
return b != 0, nil
case int16:
return b != 0, nil
case int32:
return b != 0, nil
case int64:
return b != 0, nil
case uint:
return b != 0, nil
case uint8:
return b != 0, nil
case uint16:
return b != 0, nil
case uint32:
return b != 0, nil
case uint64:
return b != 0, nil
case float32:
return b != 0, nil
case float64:
return b != 0, nil
case time.Duration:
return b != 0, nil
case string:
return strconv.ParseBool(b)
case json.Number:
v, err := ToInt64E(b)
if err == nil {
return v != 0, nil
}
return false, fmt.Errorf(errorMsg, i, i, false)
default:
if i, ok := resolveAlias(i); ok {
return ToBoolE(i)
}
return false, fmt.Errorf(errorMsg, i, i, false)
}
}
// ToStringE casts any value to a string type.
func ToStringE(i any) (string, error) {
switch s := i.(type) {
case string:
return s, nil
case bool:
return strconv.FormatBool(s), nil
case float64:
return strconv.FormatFloat(s, 'f', -1, 64), nil
case float32:
return strconv.FormatFloat(float64(s), 'f', -1, 32), nil
case int:
return strconv.Itoa(s), nil
case int8:
return strconv.FormatInt(int64(s), 10), nil
case int16:
return strconv.FormatInt(int64(s), 10), nil
case int32:
return strconv.FormatInt(int64(s), 10), nil
case int64:
return strconv.FormatInt(s, 10), nil
case uint:
return strconv.FormatUint(uint64(s), 10), nil
case uint8:
return strconv.FormatUint(uint64(s), 10), nil
case uint16:
return strconv.FormatUint(uint64(s), 10), nil
case uint32:
return strconv.FormatUint(uint64(s), 10), nil
case uint64:
return strconv.FormatUint(s, 10), nil
case json.Number:
return s.String(), nil
case []byte:
return string(s), nil
case template.HTML:
return string(s), nil
case template.URL:
return string(s), nil
case template.JS:
return string(s), nil
case template.CSS:
return string(s), nil
case template.HTMLAttr:
return string(s), nil
case nil:
return "", nil
case fmt.Stringer:
return s.String(), nil
case error:
return s.Error(), nil
default:
if i, ok := indirect(i); ok {
return ToStringE(i)
}
if i, ok := resolveAlias(i); ok {
return ToStringE(i)
}
return "", fmt.Errorf(errorMsg, i, i, "")
}
}

84
vendor/github.com/spf13/cast/cast.go generated vendored Normal file
View File

@@ -0,0 +1,84 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
// Package cast provides easy and safe casting in Go.
package cast
import "time"
const errorMsg = "unable to cast %#v of type %T to %T"
const errorMsgWith = "unable to cast %#v of type %T to %T: %w"
// Basic is a type parameter constraint for functions accepting basic types.
//
// It represents the supported basic types this package can cast to.
type Basic interface {
string | bool | Number | time.Time | time.Duration
}
// ToE casts any value to a [Basic] type.
func ToE[T Basic](i any) (T, error) {
var t T
var v any
var err error
switch any(t).(type) {
case string:
v, err = ToStringE(i)
case bool:
v, err = ToBoolE(i)
case int:
v, err = toNumberE[int](i, parseInt[int])
case int8:
v, err = toNumberE[int8](i, parseInt[int8])
case int16:
v, err = toNumberE[int16](i, parseInt[int16])
case int32:
v, err = toNumberE[int32](i, parseInt[int32])
case int64:
v, err = toNumberE[int64](i, parseInt[int64])
case uint:
v, err = toUnsignedNumberE[uint](i, parseUint[uint])
case uint8:
v, err = toUnsignedNumberE[uint8](i, parseUint[uint8])
case uint16:
v, err = toUnsignedNumberE[uint16](i, parseUint[uint16])
case uint32:
v, err = toUnsignedNumberE[uint32](i, parseUint[uint32])
case uint64:
v, err = toUnsignedNumberE[uint64](i, parseUint[uint64])
case float32:
v, err = toNumberE[float32](i, parseFloat[float32])
case float64:
v, err = toNumberE[float64](i, parseFloat[float64])
case time.Time:
v, err = ToTimeE(i)
case time.Duration:
v, err = ToDurationE(i)
}
if err != nil {
return t, err
}
return v.(T), nil
}
// Must is a helper that wraps a call to a cast function and panics if the error is non-nil.
func Must[T any](i any, err error) T {
if err != nil {
panic(err)
}
return i.(T)
}
// To casts any value to a [Basic] type.
func To[T Basic](i any) T {
v, _ := ToE[T](i)
return v
}

37
vendor/github.com/spf13/cast/indirect.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"reflect"
)
// From html/template/content.go
// Copyright 2011 The Go Authors. All rights reserved.
// indirect returns the value, after dereferencing as many times
// as necessary to reach the base type (or nil).
func indirect(i any) (any, bool) {
if i == nil {
return nil, false
}
if t := reflect.TypeOf(i); t.Kind() != reflect.Ptr {
// Avoid creating a reflect.Value if it's not a pointer.
return i, false
}
v := reflect.ValueOf(i)
for v.Kind() == reflect.Ptr || (v.Kind() == reflect.Interface && v.Elem().Kind() == reflect.Ptr) {
if v.IsNil() {
return nil, true
}
v = v.Elem()
}
return v.Interface(), true
}

79
vendor/github.com/spf13/cast/internal/time.go generated vendored Normal file
View File

@@ -0,0 +1,79 @@
package internal
import (
"fmt"
"time"
)
//go:generate stringer -type=TimeFormatType
type TimeFormatType int
const (
TimeFormatNoTimezone TimeFormatType = iota
TimeFormatNamedTimezone
TimeFormatNumericTimezone
TimeFormatNumericAndNamedTimezone
TimeFormatTimeOnly
)
type TimeFormat struct {
Format string
Typ TimeFormatType
}
func (f TimeFormat) HasTimezone() bool {
// We don't include the formats with only named timezones, see
// https://github.com/golang/go/issues/19694#issuecomment-289103522
return f.Typ >= TimeFormatNumericTimezone && f.Typ <= TimeFormatNumericAndNamedTimezone
}
var TimeFormats = []TimeFormat{
// Keep common formats at the top.
{"2006-01-02", TimeFormatNoTimezone},
{time.RFC3339, TimeFormatNumericTimezone},
{"2006-01-02T15:04:05", TimeFormatNoTimezone}, // iso8601 without timezone
{time.RFC1123Z, TimeFormatNumericTimezone},
{time.RFC1123, TimeFormatNamedTimezone},
{time.RFC822Z, TimeFormatNumericTimezone},
{time.RFC822, TimeFormatNamedTimezone},
{time.RFC850, TimeFormatNamedTimezone},
{"2006-01-02 15:04:05.999999999 -0700 MST", TimeFormatNumericAndNamedTimezone}, // Time.String()
{"2006-01-02T15:04:05-0700", TimeFormatNumericTimezone}, // RFC3339 without timezone hh:mm colon
{"2006-01-02 15:04:05Z0700", TimeFormatNumericTimezone}, // RFC3339 without T or timezone hh:mm colon
{"2006-01-02 15:04:05", TimeFormatNoTimezone},
{time.ANSIC, TimeFormatNoTimezone},
{time.UnixDate, TimeFormatNamedTimezone},
{time.RubyDate, TimeFormatNumericTimezone},
{"2006-01-02 15:04:05Z07:00", TimeFormatNumericTimezone},
{"02 Jan 2006", TimeFormatNoTimezone},
{"2006-01-02 15:04:05 -07:00", TimeFormatNumericTimezone},
{"2006-01-02 15:04:05 -0700", TimeFormatNumericTimezone},
{time.Kitchen, TimeFormatTimeOnly},
{time.Stamp, TimeFormatTimeOnly},
{time.StampMilli, TimeFormatTimeOnly},
{time.StampMicro, TimeFormatTimeOnly},
{time.StampNano, TimeFormatTimeOnly},
}
func ParseDateWith(s string, location *time.Location, formats []TimeFormat) (d time.Time, e error) {
for _, format := range formats {
if d, e = time.Parse(format.Format, s); e == nil {
// Some time formats have a zone name, but no offset, so it gets
// put in that zone name (not the default one passed in to us), but
// without that zone's offset. So set the location manually.
if format.Typ <= TimeFormatNamedTimezone {
if location == nil {
location = time.Local
}
year, month, day := d.Date()
hour, min, sec := d.Clock()
d = time.Date(year, month, day, hour, min, sec, d.Nanosecond(), location)
}
return
}
}
return d, fmt.Errorf("unable to parse date: %s", s)
}

View File

@@ -0,0 +1,27 @@
// Code generated by "stringer -type=TimeFormatType"; DO NOT EDIT.
package internal
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[TimeFormatNoTimezone-0]
_ = x[TimeFormatNamedTimezone-1]
_ = x[TimeFormatNumericTimezone-2]
_ = x[TimeFormatNumericAndNamedTimezone-3]
_ = x[TimeFormatTimeOnly-4]
}
const _TimeFormatType_name = "TimeFormatNoTimezoneTimeFormatNamedTimezoneTimeFormatNumericTimezoneTimeFormatNumericAndNamedTimezoneTimeFormatTimeOnly"
var _TimeFormatType_index = [...]uint8{0, 20, 43, 68, 101, 119}
func (i TimeFormatType) String() string {
if i < 0 || i >= TimeFormatType(len(_TimeFormatType_index)-1) {
return "TimeFormatType(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _TimeFormatType_name[_TimeFormatType_index[i]:_TimeFormatType_index[i+1]]
}

224
vendor/github.com/spf13/cast/map.go generated vendored Normal file
View File

@@ -0,0 +1,224 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"encoding/json"
"fmt"
"reflect"
)
func toMapE[K comparable, V any](i any, keyFn func(any) K, valFn func(any) V) (map[K]V, error) {
m := map[K]V{}
if i == nil {
return nil, fmt.Errorf(errorMsg, i, i, m)
}
switch v := i.(type) {
case map[K]V:
return v, nil
case map[K]any:
for k, val := range v {
m[k] = valFn(val)
}
return m, nil
case map[any]V:
for k, val := range v {
m[keyFn(k)] = val
}
return m, nil
case map[any]any:
for k, val := range v {
m[keyFn(k)] = valFn(val)
}
return m, nil
case string:
err := jsonStringToObject(v, &m)
if err != nil {
return nil, err
}
return m, nil
default:
return nil, fmt.Errorf(errorMsg, i, i, m)
}
}
func toStringMapE[T any](i any, fn func(any) T) (map[string]T, error) {
return toMapE(i, ToString, fn)
}
// ToStringMapStringE casts any value to a map[string]string type.
func ToStringMapStringE(i any) (map[string]string, error) {
return toStringMapE(i, ToString)
}
// ToStringMapStringSliceE casts any value to a map[string][]string type.
func ToStringMapStringSliceE(i any) (map[string][]string, error) {
m := map[string][]string{}
switch v := i.(type) {
case map[string][]string:
return v, nil
case map[string][]any:
for k, val := range v {
m[ToString(k)] = ToStringSlice(val)
}
return m, nil
case map[string]string:
for k, val := range v {
m[ToString(k)] = []string{val}
}
case map[string]any:
for k, val := range v {
switch vt := val.(type) {
case []any:
m[ToString(k)] = ToStringSlice(vt)
case []string:
m[ToString(k)] = vt
default:
m[ToString(k)] = []string{ToString(val)}
}
}
return m, nil
case map[any][]string:
for k, val := range v {
m[ToString(k)] = ToStringSlice(val)
}
return m, nil
case map[any]string:
for k, val := range v {
m[ToString(k)] = ToStringSlice(val)
}
return m, nil
case map[any][]any:
for k, val := range v {
m[ToString(k)] = ToStringSlice(val)
}
return m, nil
case map[any]any:
for k, val := range v {
key, err := ToStringE(k)
if err != nil {
return nil, fmt.Errorf(errorMsg, i, i, m)
}
value, err := ToStringSliceE(val)
if err != nil {
return nil, fmt.Errorf(errorMsg, i, i, m)
}
m[key] = value
}
case string:
err := jsonStringToObject(v, &m)
if err != nil {
return nil, err
}
return m, nil
default:
return nil, fmt.Errorf(errorMsg, i, i, m)
}
return m, nil
}
// ToStringMapBoolE casts any value to a map[string]bool type.
func ToStringMapBoolE(i any) (map[string]bool, error) {
return toStringMapE(i, ToBool)
}
// ToStringMapE casts any value to a map[string]any type.
func ToStringMapE(i any) (map[string]any, error) {
fn := func(i any) any { return i }
return toStringMapE(i, fn)
}
func toStringMapIntE[T int | int64](i any, fn func(any) T, fnE func(any) (T, error)) (map[string]T, error) {
m := map[string]T{}
if i == nil {
return nil, fmt.Errorf(errorMsg, i, i, m)
}
switch v := i.(type) {
case map[string]T:
return v, nil
case map[string]any:
for k, val := range v {
m[k] = fn(val)
}
return m, nil
case map[any]T:
for k, val := range v {
m[ToString(k)] = val
}
return m, nil
case map[any]any:
for k, val := range v {
m[ToString(k)] = fn(val)
}
return m, nil
case string:
err := jsonStringToObject(v, &m)
if err != nil {
return nil, err
}
return m, nil
}
if reflect.TypeOf(i).Kind() != reflect.Map {
return nil, fmt.Errorf(errorMsg, i, i, m)
}
mVal := reflect.ValueOf(m)
v := reflect.ValueOf(i)
for _, keyVal := range v.MapKeys() {
val, err := fnE(v.MapIndex(keyVal).Interface())
if err != nil {
return m, fmt.Errorf(errorMsg, i, i, m)
}
mVal.SetMapIndex(keyVal, reflect.ValueOf(val))
}
return m, nil
}
// ToStringMapIntE casts any value to a map[string]int type.
func ToStringMapIntE(i any) (map[string]int, error) {
return toStringMapIntE(i, ToInt, ToIntE)
}
// ToStringMapInt64E casts any value to a map[string]int64 type.
func ToStringMapInt64E(i any) (map[string]int64, error) {
return toStringMapIntE(i, ToInt64, ToInt64E)
}
// jsonStringToObject attempts to unmarshall a string as JSON into
// the object passed as pointer.
func jsonStringToObject(s string, v any) error {
data := []byte(s)
return json.Unmarshal(data, v)
}

549
vendor/github.com/spf13/cast/number.go generated vendored Normal file
View File

@@ -0,0 +1,549 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"encoding/json"
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"time"
)
var errNegativeNotAllowed = errors.New("unable to cast negative value")
type float64EProvider interface {
Float64() (float64, error)
}
type float64Provider interface {
Float64() float64
}
// Number is a type parameter constraint for functions accepting number types.
//
// It represents the supported number types this package can cast to.
type Number interface {
int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}
type integer interface {
int | int8 | int16 | int32 | int64
}
type unsigned interface {
uint | uint8 | uint16 | uint32 | uint64
}
type float interface {
float32 | float64
}
// ToNumberE casts any value to a [Number] type.
func ToNumberE[T Number](i any) (T, error) {
var t T
switch any(t).(type) {
case int:
return toNumberE[T](i, parseNumber[T])
case int8:
return toNumberE[T](i, parseNumber[T])
case int16:
return toNumberE[T](i, parseNumber[T])
case int32:
return toNumberE[T](i, parseNumber[T])
case int64:
return toNumberE[T](i, parseNumber[T])
case uint:
return toUnsignedNumberE[T](i, parseNumber[T])
case uint8:
return toUnsignedNumberE[T](i, parseNumber[T])
case uint16:
return toUnsignedNumberE[T](i, parseNumber[T])
case uint32:
return toUnsignedNumberE[T](i, parseNumber[T])
case uint64:
return toUnsignedNumberE[T](i, parseNumber[T])
case float32:
return toNumberE[T](i, parseNumber[T])
case float64:
return toNumberE[T](i, parseNumber[T])
default:
return 0, fmt.Errorf("unknown number type: %T", t)
}
}
// ToNumber casts any value to a [Number] type.
func ToNumber[T Number](i any) T {
v, _ := ToNumberE[T](i)
return v
}
// toNumber's semantics differ from other "to" functions.
// It returns false as the second parameter if the conversion fails.
// This is to signal other callers that they should proceed with their own conversions.
func toNumber[T Number](i any) (T, bool) {
i, _ = indirect(i)
switch s := i.(type) {
case T:
return s, true
case int:
return T(s), true
case int8:
return T(s), true
case int16:
return T(s), true
case int32:
return T(s), true
case int64:
return T(s), true
case uint:
return T(s), true
case uint8:
return T(s), true
case uint16:
return T(s), true
case uint32:
return T(s), true
case uint64:
return T(s), true
case float32:
return T(s), true
case float64:
return T(s), true
case bool:
if s {
return 1, true
}
return 0, true
case nil:
return 0, true
case time.Weekday:
return T(s), true
case time.Month:
return T(s), true
}
return 0, false
}
func toNumberE[T Number](i any, parseFn func(string) (T, error)) (T, error) {
n, ok := toNumber[T](i)
if ok {
return n, nil
}
i, _ = indirect(i)
switch s := i.(type) {
case string:
if s == "" {
return 0, nil
}
v, err := parseFn(s)
if err != nil {
return 0, fmt.Errorf(errorMsgWith, i, i, n, err)
}
return v, nil
case json.Number:
if s == "" {
return 0, nil
}
v, err := parseFn(string(s))
if err != nil {
return 0, fmt.Errorf(errorMsgWith, i, i, n, err)
}
return v, nil
case float64EProvider:
if _, ok := any(n).(float64); !ok {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
v, err := s.Float64()
if err != nil {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
return T(v), nil
case float64Provider:
if _, ok := any(n).(float64); !ok {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
return T(s.Float64()), nil
default:
if i, ok := resolveAlias(i); ok {
return toNumberE(i, parseFn)
}
return 0, fmt.Errorf(errorMsg, i, i, n)
}
}
func toUnsignedNumber[T Number](i any) (T, bool, bool) {
i, _ = indirect(i)
switch s := i.(type) {
case T:
return s, true, true
case int:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case int8:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case int16:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case int32:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case int64:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case uint:
return T(s), true, true
case uint8:
return T(s), true, true
case uint16:
return T(s), true, true
case uint32:
return T(s), true, true
case uint64:
return T(s), true, true
case float32:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case float64:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case bool:
if s {
return 1, true, true
}
return 0, true, true
case nil:
return 0, true, true
case time.Weekday:
if s < 0 {
return 0, false, false
}
return T(s), true, true
case time.Month:
if s < 0 {
return 0, false, false
}
return T(s), true, true
}
return 0, true, false
}
func toUnsignedNumberE[T Number](i any, parseFn func(string) (T, error)) (T, error) {
n, valid, ok := toUnsignedNumber[T](i)
if ok {
return n, nil
}
i, _ = indirect(i)
if !valid {
return 0, errNegativeNotAllowed
}
switch s := i.(type) {
case string:
if s == "" {
return 0, nil
}
v, err := parseFn(s)
if err != nil {
return 0, fmt.Errorf(errorMsgWith, i, i, n, err)
}
return v, nil
case json.Number:
if s == "" {
return 0, nil
}
v, err := parseFn(string(s))
if err != nil {
return 0, fmt.Errorf(errorMsgWith, i, i, n, err)
}
return v, nil
case float64EProvider:
if _, ok := any(n).(float64); !ok {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
v, err := s.Float64()
if err != nil {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
if v < 0 {
return 0, errNegativeNotAllowed
}
return T(v), nil
case float64Provider:
if _, ok := any(n).(float64); !ok {
return 0, fmt.Errorf(errorMsg, i, i, n)
}
v := s.Float64()
if v < 0 {
return 0, errNegativeNotAllowed
}
return T(v), nil
default:
if i, ok := resolveAlias(i); ok {
return toUnsignedNumberE(i, parseFn)
}
return 0, fmt.Errorf(errorMsg, i, i, n)
}
}
func parseNumber[T Number](s string) (T, error) {
var t T
switch any(t).(type) {
case int:
v, err := parseInt[int](s)
return T(v), err
case int8:
v, err := parseInt[int8](s)
return T(v), err
case int16:
v, err := parseInt[int16](s)
return T(v), err
case int32:
v, err := parseInt[int32](s)
return T(v), err
case int64:
v, err := parseInt[int64](s)
return T(v), err
case uint:
v, err := parseUint[uint](s)
return T(v), err
case uint8:
v, err := parseUint[uint8](s)
return T(v), err
case uint16:
v, err := parseUint[uint16](s)
return T(v), err
case uint32:
v, err := parseUint[uint32](s)
return T(v), err
case uint64:
v, err := parseUint[uint64](s)
return T(v), err
case float32:
v, err := strconv.ParseFloat(s, 32)
return T(v), err
case float64:
v, err := strconv.ParseFloat(s, 64)
return T(v), err
default:
return 0, fmt.Errorf("unknown number type: %T", t)
}
}
func parseInt[T integer](s string) (T, error) {
v, err := strconv.ParseInt(trimDecimal(s), 0, 0)
if err != nil {
return 0, err
}
return T(v), nil
}
func parseUint[T unsigned](s string) (T, error) {
v, err := strconv.ParseUint(strings.TrimLeft(trimDecimal(s), "+"), 0, 0)
if err != nil {
return 0, err
}
return T(v), nil
}
func parseFloat[T float](s string) (T, error) {
var t T
var v any
var err error
switch any(t).(type) {
case float32:
n, e := strconv.ParseFloat(s, 32)
v = float32(n)
err = e
case float64:
n, e := strconv.ParseFloat(s, 64)
v = float64(n)
err = e
}
return v.(T), err
}
// ToFloat64E casts an interface to a float64 type.
func ToFloat64E(i any) (float64, error) {
return toNumberE[float64](i, parseFloat[float64])
}
// ToFloat32E casts an interface to a float32 type.
func ToFloat32E(i any) (float32, error) {
return toNumberE[float32](i, parseFloat[float32])
}
// ToInt64E casts an interface to an int64 type.
func ToInt64E(i any) (int64, error) {
return toNumberE[int64](i, parseInt[int64])
}
// ToInt32E casts an interface to an int32 type.
func ToInt32E(i any) (int32, error) {
return toNumberE[int32](i, parseInt[int32])
}
// ToInt16E casts an interface to an int16 type.
func ToInt16E(i any) (int16, error) {
return toNumberE[int16](i, parseInt[int16])
}
// ToInt8E casts an interface to an int8 type.
func ToInt8E(i any) (int8, error) {
return toNumberE[int8](i, parseInt[int8])
}
// ToIntE casts an interface to an int type.
func ToIntE(i any) (int, error) {
return toNumberE[int](i, parseInt[int])
}
// ToUintE casts an interface to a uint type.
func ToUintE(i any) (uint, error) {
return toUnsignedNumberE[uint](i, parseUint[uint])
}
// ToUint64E casts an interface to a uint64 type.
func ToUint64E(i any) (uint64, error) {
return toUnsignedNumberE[uint64](i, parseUint[uint64])
}
// ToUint32E casts an interface to a uint32 type.
func ToUint32E(i any) (uint32, error) {
return toUnsignedNumberE[uint32](i, parseUint[uint32])
}
// ToUint16E casts an interface to a uint16 type.
func ToUint16E(i any) (uint16, error) {
return toUnsignedNumberE[uint16](i, parseUint[uint16])
}
// ToUint8E casts an interface to a uint type.
func ToUint8E(i any) (uint8, error) {
return toUnsignedNumberE[uint8](i, parseUint[uint8])
}
func trimZeroDecimal(s string) string {
var foundZero bool
for i := len(s); i > 0; i-- {
switch s[i-1] {
case '.':
if foundZero {
return s[:i-1]
}
case '0':
foundZero = true
default:
return s
}
}
return s
}
var stringNumberRe = regexp.MustCompile(`^([-+]?\d*)(\.\d*)?$`)
// see [BenchmarkDecimal] for details about the implementation
func trimDecimal(s string) string {
if !strings.Contains(s, ".") {
return s
}
matches := stringNumberRe.FindStringSubmatch(s)
if matches != nil {
// matches[1] is the captured integer part with sign
s = matches[1]
// handle special cases
switch s {
case "-", "+":
s += "0"
case "":
s = "0"
}
return s
}
return s
}

106
vendor/github.com/spf13/cast/slice.go generated vendored Normal file
View File

@@ -0,0 +1,106 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"fmt"
"reflect"
"strings"
)
// ToSliceE casts any value to a []any type.
func ToSliceE(i any) ([]any, error) {
i, _ = indirect(i)
var s []any
switch v := i.(type) {
case []any:
// TODO: use slices.Clone
return append(s, v...), nil
case []map[string]any:
for _, u := range v {
s = append(s, u)
}
return s, nil
default:
return s, fmt.Errorf(errorMsg, i, i, s)
}
}
func toSliceE[T Basic](i any) ([]T, error) {
v, ok, err := toSliceEOk[T](i)
if err != nil {
return nil, err
}
if !ok {
return nil, fmt.Errorf(errorMsg, i, i, []T{})
}
return v, nil
}
func toSliceEOk[T Basic](i any) ([]T, bool, error) {
i, _ = indirect(i)
if i == nil {
return nil, true, fmt.Errorf(errorMsg, i, i, []T{})
}
switch v := i.(type) {
case []T:
// TODO: clone slice
return v, true, nil
}
kind := reflect.TypeOf(i).Kind()
switch kind {
case reflect.Slice, reflect.Array:
s := reflect.ValueOf(i)
a := make([]T, s.Len())
for j := 0; j < s.Len(); j++ {
val, err := ToE[T](s.Index(j).Interface())
if err != nil {
return nil, true, fmt.Errorf(errorMsg, i, i, []T{})
}
a[j] = val
}
return a, true, nil
default:
return nil, false, nil
}
}
// ToStringSliceE casts any value to a []string type.
func ToStringSliceE(i any) ([]string, error) {
if a, ok, err := toSliceEOk[string](i); ok {
if err != nil {
return nil, err
}
return a, nil
}
var a []string
switch v := i.(type) {
case string:
return strings.Fields(v), nil
case any:
str, err := ToStringE(v)
if err != nil {
return nil, fmt.Errorf(errorMsg, i, i, a)
}
return []string{str}, nil
default:
return nil, fmt.Errorf(errorMsg, i, i, a)
}
}

116
vendor/github.com/spf13/cast/time.go generated vendored Normal file
View File

@@ -0,0 +1,116 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package cast
import (
"encoding/json"
"errors"
"fmt"
"strings"
"time"
"github.com/spf13/cast/internal"
)
// ToTimeE any value to a [time.Time] type.
func ToTimeE(i any) (time.Time, error) {
return ToTimeInDefaultLocationE(i, time.UTC)
}
// ToTimeInDefaultLocationE casts an empty interface to [time.Time],
// interpreting inputs without a timezone to be in the given location,
// or the local timezone if nil.
func ToTimeInDefaultLocationE(i any, location *time.Location) (tim time.Time, err error) {
i, _ = indirect(i)
switch v := i.(type) {
case time.Time:
return v, nil
case string:
return StringToDateInDefaultLocation(v, location)
case json.Number:
// Originally this used ToInt64E, but adding string float conversion broke ToTime.
// the behavior of ToTime would have changed if we continued using it.
// For now, using json.Number's own Int64 method should be good enough to preserve backwards compatibility.
v = json.Number(trimZeroDecimal(string(v)))
s, err1 := v.Int64()
if err1 != nil {
return time.Time{}, fmt.Errorf(errorMsg, i, i, time.Time{})
}
return time.Unix(s, 0), nil
case int:
return time.Unix(int64(v), 0), nil
case int32:
return time.Unix(int64(v), 0), nil
case int64:
return time.Unix(v, 0), nil
case uint:
return time.Unix(int64(v), 0), nil
case uint32:
return time.Unix(int64(v), 0), nil
case uint64:
return time.Unix(int64(v), 0), nil
case nil:
return time.Time{}, nil
default:
return time.Time{}, fmt.Errorf(errorMsg, i, i, time.Time{})
}
}
// ToDurationE casts any value to a [time.Duration] type.
func ToDurationE(i any) (time.Duration, error) {
i, _ = indirect(i)
switch s := i.(type) {
case time.Duration:
return s, nil
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
v, err := ToInt64E(s)
if err != nil {
// TODO: once there is better error handling, this should be easier
return 0, errors.New(strings.ReplaceAll(err.Error(), " int64", "time.Duration"))
}
return time.Duration(v), nil
case float32, float64, float64EProvider, float64Provider:
v, err := ToFloat64E(s)
if err != nil {
// TODO: once there is better error handling, this should be easier
return 0, errors.New(strings.ReplaceAll(err.Error(), " float64", "time.Duration"))
}
return time.Duration(v), nil
case string:
if !strings.ContainsAny(s, "nsuµmh") {
return time.ParseDuration(s + "ns")
}
return time.ParseDuration(s)
case nil:
return time.Duration(0), nil
default:
if i, ok := resolveAlias(i); ok {
return ToDurationE(i)
}
return 0, fmt.Errorf(errorMsg, i, i, time.Duration(0))
}
}
// StringToDate attempts to parse a string into a [time.Time] type using a
// predefined list of formats.
//
// If no suitable format is found, an error is returned.
func StringToDate(s string) (time.Time, error) {
return internal.ParseDateWith(s, time.UTC, internal.TimeFormats)
}
// StringToDateInDefaultLocation casts an empty interface to a [time.Time],
// interpreting inputs without a timezone to be in the given location,
// or the local timezone if nil.
func StringToDateInDefaultLocation(s string, location *time.Location) (time.Time, error) {
return internal.ParseDateWith(s, location, internal.TimeFormats)
}

261
vendor/github.com/spf13/cast/zz_generated.go generated vendored Normal file
View File

@@ -0,0 +1,261 @@
// Code generated by cast generator. DO NOT EDIT.
package cast
import "time"
// ToBool casts any value to a(n) bool type.
func ToBool(i any) bool {
v, _ := ToBoolE(i)
return v
}
// ToString casts any value to a(n) string type.
func ToString(i any) string {
v, _ := ToStringE(i)
return v
}
// ToTime casts any value to a(n) time.Time type.
func ToTime(i any) time.Time {
v, _ := ToTimeE(i)
return v
}
// ToTimeInDefaultLocation casts any value to a(n) time.Time type.
func ToTimeInDefaultLocation(i any, location *time.Location) time.Time {
v, _ := ToTimeInDefaultLocationE(i, location)
return v
}
// ToDuration casts any value to a(n) time.Duration type.
func ToDuration(i any) time.Duration {
v, _ := ToDurationE(i)
return v
}
// ToInt casts any value to a(n) int type.
func ToInt(i any) int {
v, _ := ToIntE(i)
return v
}
// ToInt8 casts any value to a(n) int8 type.
func ToInt8(i any) int8 {
v, _ := ToInt8E(i)
return v
}
// ToInt16 casts any value to a(n) int16 type.
func ToInt16(i any) int16 {
v, _ := ToInt16E(i)
return v
}
// ToInt32 casts any value to a(n) int32 type.
func ToInt32(i any) int32 {
v, _ := ToInt32E(i)
return v
}
// ToInt64 casts any value to a(n) int64 type.
func ToInt64(i any) int64 {
v, _ := ToInt64E(i)
return v
}
// ToUint casts any value to a(n) uint type.
func ToUint(i any) uint {
v, _ := ToUintE(i)
return v
}
// ToUint8 casts any value to a(n) uint8 type.
func ToUint8(i any) uint8 {
v, _ := ToUint8E(i)
return v
}
// ToUint16 casts any value to a(n) uint16 type.
func ToUint16(i any) uint16 {
v, _ := ToUint16E(i)
return v
}
// ToUint32 casts any value to a(n) uint32 type.
func ToUint32(i any) uint32 {
v, _ := ToUint32E(i)
return v
}
// ToUint64 casts any value to a(n) uint64 type.
func ToUint64(i any) uint64 {
v, _ := ToUint64E(i)
return v
}
// ToFloat32 casts any value to a(n) float32 type.
func ToFloat32(i any) float32 {
v, _ := ToFloat32E(i)
return v
}
// ToFloat64 casts any value to a(n) float64 type.
func ToFloat64(i any) float64 {
v, _ := ToFloat64E(i)
return v
}
// ToStringMapString casts any value to a(n) map[string]string type.
func ToStringMapString(i any) map[string]string {
v, _ := ToStringMapStringE(i)
return v
}
// ToStringMapStringSlice casts any value to a(n) map[string][]string type.
func ToStringMapStringSlice(i any) map[string][]string {
v, _ := ToStringMapStringSliceE(i)
return v
}
// ToStringMapBool casts any value to a(n) map[string]bool type.
func ToStringMapBool(i any) map[string]bool {
v, _ := ToStringMapBoolE(i)
return v
}
// ToStringMapInt casts any value to a(n) map[string]int type.
func ToStringMapInt(i any) map[string]int {
v, _ := ToStringMapIntE(i)
return v
}
// ToStringMapInt64 casts any value to a(n) map[string]int64 type.
func ToStringMapInt64(i any) map[string]int64 {
v, _ := ToStringMapInt64E(i)
return v
}
// ToStringMap casts any value to a(n) map[string]any type.
func ToStringMap(i any) map[string]any {
v, _ := ToStringMapE(i)
return v
}
// ToSlice casts any value to a(n) []any type.
func ToSlice(i any) []any {
v, _ := ToSliceE(i)
return v
}
// ToBoolSlice casts any value to a(n) []bool type.
func ToBoolSlice(i any) []bool {
v, _ := ToBoolSliceE(i)
return v
}
// ToStringSlice casts any value to a(n) []string type.
func ToStringSlice(i any) []string {
v, _ := ToStringSliceE(i)
return v
}
// ToIntSlice casts any value to a(n) []int type.
func ToIntSlice(i any) []int {
v, _ := ToIntSliceE(i)
return v
}
// ToInt64Slice casts any value to a(n) []int64 type.
func ToInt64Slice(i any) []int64 {
v, _ := ToInt64SliceE(i)
return v
}
// ToUintSlice casts any value to a(n) []uint type.
func ToUintSlice(i any) []uint {
v, _ := ToUintSliceE(i)
return v
}
// ToFloat64Slice casts any value to a(n) []float64 type.
func ToFloat64Slice(i any) []float64 {
v, _ := ToFloat64SliceE(i)
return v
}
// ToDurationSlice casts any value to a(n) []time.Duration type.
func ToDurationSlice(i any) []time.Duration {
v, _ := ToDurationSliceE(i)
return v
}
// ToBoolSliceE casts any value to a(n) []bool type.
func ToBoolSliceE(i any) ([]bool, error) {
return toSliceE[bool](i)
}
// ToDurationSliceE casts any value to a(n) []time.Duration type.
func ToDurationSliceE(i any) ([]time.Duration, error) {
return toSliceE[time.Duration](i)
}
// ToIntSliceE casts any value to a(n) []int type.
func ToIntSliceE(i any) ([]int, error) {
return toSliceE[int](i)
}
// ToInt8SliceE casts any value to a(n) []int8 type.
func ToInt8SliceE(i any) ([]int8, error) {
return toSliceE[int8](i)
}
// ToInt16SliceE casts any value to a(n) []int16 type.
func ToInt16SliceE(i any) ([]int16, error) {
return toSliceE[int16](i)
}
// ToInt32SliceE casts any value to a(n) []int32 type.
func ToInt32SliceE(i any) ([]int32, error) {
return toSliceE[int32](i)
}
// ToInt64SliceE casts any value to a(n) []int64 type.
func ToInt64SliceE(i any) ([]int64, error) {
return toSliceE[int64](i)
}
// ToUintSliceE casts any value to a(n) []uint type.
func ToUintSliceE(i any) ([]uint, error) {
return toSliceE[uint](i)
}
// ToUint8SliceE casts any value to a(n) []uint8 type.
func ToUint8SliceE(i any) ([]uint8, error) {
return toSliceE[uint8](i)
}
// ToUint16SliceE casts any value to a(n) []uint16 type.
func ToUint16SliceE(i any) ([]uint16, error) {
return toSliceE[uint16](i)
}
// ToUint32SliceE casts any value to a(n) []uint32 type.
func ToUint32SliceE(i any) ([]uint32, error) {
return toSliceE[uint32](i)
}
// ToUint64SliceE casts any value to a(n) []uint64 type.
func ToUint64SliceE(i any) ([]uint64, error) {
return toSliceE[uint64](i)
}
// ToFloat32SliceE casts any value to a(n) []float32 type.
func ToFloat32SliceE(i any) ([]float32, error) {
return toSliceE[float32](i)
}
// ToFloat64SliceE casts any value to a(n) []float64 type.
func ToFloat64SliceE(i any) ([]float64, error) {
return toSliceE[float64](i)
}