|
|
|
|
/* ——————————————————————————————————————————————————————————————————————————
|
|
|
|
|
Proyecto goat
|
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
|
Fichero a.go
|
|
|
|
|
Package cvls
|
|
|
|
|
Autor Juan V. Navarro juanvnl@activething.com
|
|
|
|
|
Creado 05/02/2026
|
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
|
|
|
|
|
|
LICENSES AND TERMS OF USE
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
This software is licensed under the Elastic License v2.0 (the "License").
|
|
|
|
|
For full terms and additional information regarding permitted and prohibited
|
|
|
|
|
uses, please visit:
|
|
|
|
|
https://activething.com/ATGO/licenses
|
|
|
|
|
|
|
|
|
|
You may use, copy, modify, and redistribute this software internally within
|
|
|
|
|
your organization for any purpose, including research, development, and
|
|
|
|
|
testing, subject to the terms of this License.
|
|
|
|
|
|
|
|
|
|
You may NOT, however, use, provide, distribute, or make this software
|
|
|
|
|
available to any third party as part of a hosted service, SaaS offering, or
|
|
|
|
|
commercial product without first obtaining a commercial license from
|
|
|
|
|
Active Thing.
|
|
|
|
|
|
|
|
|
|
You may combine this software with other code, provided that such
|
|
|
|
|
combination does not circumvent the restrictions of this License.
|
|
|
|
|
|
|
|
|
|
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 NON-INFRINGEMENT. In no event shall
|
|
|
|
|
the authors or copyright holders be liable for any claim, damages, or other
|
|
|
|
|
liability arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
|
|
|
|
|
|
Web : activething.com | activething.com/goat
|
|
|
|
|
git : g.activething.com | github.com/activething/goat
|
|
|
|
|
Correo : dev@activething.com
|
|
|
|
|
|
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
|
No deseo caminar sobre el agua", dijo Siddhartha.
|
|
|
|
|
Que los antiguos chamanes se contenten con tales habilidades.
|
|
|
|
|
—— Hermann Hesse, Siddhartha
|
|
|
|
|
—————————————————————————————————————————————————————————————————————————————
|
|
|
|
|
Copyright (c) 2026 Active Thing
|
|
|
|
|
————————————————————————————————————————————————————————————————————————————— */
|
|
|
|
|
|
|
|
|
|
package cvls
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"core/errs"
|
|
|
|
|
"crypto"
|
|
|
|
|
"fmt"
|
|
|
|
|
"math"
|
|
|
|
|
"math/big"
|
|
|
|
|
"reflect"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
Bytes = []uint8
|
|
|
|
|
Stack = []struct{ Line string }
|
|
|
|
|
UUID = [16]byte
|
|
|
|
|
|
|
|
|
|
Reflect = reflect.Value
|
|
|
|
|
Date = time.Time
|
|
|
|
|
Duration = time.Duration
|
|
|
|
|
|
|
|
|
|
Stringer = fmt.Stringer
|
|
|
|
|
Packable = interface{ pack() []byte }
|
|
|
|
|
|
|
|
|
|
BigInt = big.Int
|
|
|
|
|
HashAlg = crypto.Hash
|
|
|
|
|
|
|
|
|
|
Context = context.Context
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
ints interface {
|
|
|
|
|
int | int8 | int16 | int32 | int64 | Duration
|
|
|
|
|
}
|
|
|
|
|
uints interface {
|
|
|
|
|
uint | uint8 | uint16 | uint32 | uint64 | uintptr | HashAlg
|
|
|
|
|
}
|
|
|
|
|
cmplx interface{
|
|
|
|
|
complex64 | complex128
|
|
|
|
|
}
|
|
|
|
|
lists interface{
|
|
|
|
|
Bytes | Stack
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
Module = errs.Module("cvls")
|
|
|
|
|
|
|
|
|
|
ErrInvalidCValueReflected = Module.MustCode("invalid_reflect_value")
|
|
|
|
|
ErrInvalidCValueForType = Module.MustCode("invalid_value_for_type")
|
|
|
|
|
|
|
|
|
|
uuidZero = UUID{}
|
|
|
|
|
|
|
|
|
|
specs = newSpecInfos()
|
|
|
|
|
|
|
|
|
|
kindNames = []string{
|
|
|
|
|
"any",
|
|
|
|
|
"bool",
|
|
|
|
|
|
|
|
|
|
"int",
|
|
|
|
|
"int8",
|
|
|
|
|
"int16",
|
|
|
|
|
"int32",
|
|
|
|
|
"int64",
|
|
|
|
|
"duration",
|
|
|
|
|
|
|
|
|
|
"uint",
|
|
|
|
|
"uint8",
|
|
|
|
|
"uint16",
|
|
|
|
|
"uint32",
|
|
|
|
|
"uint64",
|
|
|
|
|
"uintptr",
|
|
|
|
|
"hashAlg",
|
|
|
|
|
|
|
|
|
|
"float32",
|
|
|
|
|
"float64",
|
|
|
|
|
"complex64",
|
|
|
|
|
"complex128",
|
|
|
|
|
|
|
|
|
|
"string",
|
|
|
|
|
"bytes",
|
|
|
|
|
"stack",
|
|
|
|
|
"uuid",
|
|
|
|
|
|
|
|
|
|
"date",
|
|
|
|
|
"reflect",
|
|
|
|
|
"object",
|
|
|
|
|
|
|
|
|
|
"packable",
|
|
|
|
|
"stringer",
|
|
|
|
|
"error",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
specNames = []string{
|
|
|
|
|
"scalar",
|
|
|
|
|
"defer",
|
|
|
|
|
"list",
|
|
|
|
|
"map",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stateNames = [6]string{
|
|
|
|
|
"invalid",
|
|
|
|
|
"error",
|
|
|
|
|
"nil",
|
|
|
|
|
"zero",
|
|
|
|
|
"version",
|
|
|
|
|
"reflected",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fieldVisibilityNames = [4]string{
|
|
|
|
|
"public",
|
|
|
|
|
"internal",
|
|
|
|
|
"sensitive",
|
|
|
|
|
"no_loggable",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fieldEncodingNames = [4]string{
|
|
|
|
|
"plain",
|
|
|
|
|
"encoded",
|
|
|
|
|
"encrypted",
|
|
|
|
|
"hashed",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fieldBehaviorNames = [3]string{
|
|
|
|
|
"omitempty",
|
|
|
|
|
"required",
|
|
|
|
|
"indexed",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func UnixMinMaxTime() (time.Time, time.Time) {
|
|
|
|
|
const billion = int64(1_000_000_000) // nanosegundos en un segundo
|
|
|
|
|
// --- Min ---
|
|
|
|
|
minSec := math.MinInt64 / billion
|
|
|
|
|
minNsec := math.MinInt64 % billion
|
|
|
|
|
if minNsec < 0 {
|
|
|
|
|
minSec--
|
|
|
|
|
minNsec += billion
|
|
|
|
|
}
|
|
|
|
|
minTime := time.Unix(minSec, minNsec)
|
|
|
|
|
|
|
|
|
|
// --- Max ---
|
|
|
|
|
maxSec := math.MaxInt64 / billion
|
|
|
|
|
maxNsec := math.MaxInt64 % billion
|
|
|
|
|
if maxNsec < 0 {
|
|
|
|
|
maxSec--
|
|
|
|
|
maxNsec += billion
|
|
|
|
|
}
|
|
|
|
|
maxTime := time.Unix(maxSec, maxNsec)
|
|
|
|
|
|
|
|
|
|
return minTime, maxTime
|
|
|
|
|
}
|