You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
988 B
74 lines
988 B
package main
|
|
|
|
import (
|
|
"apack/pkjson"
|
|
"blds"
|
|
"errs"
|
|
"errs/eftext"
|
|
"fmt"
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
|
|
S struct {
|
|
A string
|
|
}
|
|
)
|
|
|
|
func Una () S {
|
|
fmt.Println("Es llamado ")
|
|
return S { A : "Un valiue" }
|
|
}
|
|
|
|
func randomInt(min, max int) int {
|
|
rand.Seed(time.Now().UnixNano()) // Semilla para generar números aleatorios únicos
|
|
return rand.Intn(max-min+1) + min
|
|
}
|
|
|
|
|
|
func (s S) Build (b blds.Builder) {
|
|
b.String("Esto es un campo S")
|
|
}
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
|
|
p := pkjson.NewPacker()
|
|
|
|
|
|
|
|
myMap := map[interface{}]interface{}{
|
|
1: "uno",
|
|
"dos": 2,
|
|
3.0: true,
|
|
true: 4.5,
|
|
"cinco": "seis",
|
|
7: 8,
|
|
"nueve": false,
|
|
10.11: "doce",
|
|
false: 13,
|
|
"catorce": 15.16,
|
|
"dfate": time.Now(),
|
|
time.Now(): "ff",
|
|
"SSSS" : S{A:"a"},
|
|
}
|
|
|
|
|
|
|
|
|
|
r := p.Pack(myMap)
|
|
if !r.Ok() {
|
|
fmt.Printf("%s \n",string(errs.Encode(r.Fail(), eftext.Formatter())))
|
|
return
|
|
}
|
|
|
|
fmt.Printf("Data\n\n%s",string(r.Value()))
|
|
|
|
}
|