Init
This commit is contained in:
parent
fce8da40f0
commit
6e0fb377b8
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "${workspaceFolder}/main.go"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module github.com/rayaman/squish
|
||||||
|
|
||||||
|
go 1.22.4
|
||||||
|
|
||||||
|
require github.com/fatih/structs v1.1.0 // indirect
|
||||||
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||||
|
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||||
13
main.go
Normal file
13
main.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/rayaman/squish/encoding"
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Name string `binary:"limit=24"` // no
|
||||||
|
Age int `binary:""`
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
user := &User{Name: "Ryan Ward", Age: 28}
|
||||||
|
encoding.GetOptions(user)
|
||||||
|
}
|
||||||
33
pkg/encoding/encoding.go
Normal file
33
pkg/encoding/encoding.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package encoding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fatih/structs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type options struct {
|
||||||
|
max int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOptions(obj any) options {
|
||||||
|
fields := structs.Fields(obj)
|
||||||
|
for _, field := range fields {
|
||||||
|
tag := field.Tag("binary")
|
||||||
|
tags := strings.Split(tag, ",")
|
||||||
|
fmt.Println(tags)
|
||||||
|
for _, val := range tags {
|
||||||
|
fmt.Println(strings.Split(val, "="))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Marshal(obj any, version int16) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Unmarshal(data []byte) (any, int16, error) {
|
||||||
|
return nil, 0, nil
|
||||||
|
}
|
||||||
1
pkg/utils/utils.go
Normal file
1
pkg/utils/utils.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package utils
|
||||||
Loading…
x
Reference in New Issue
Block a user