chore: add avro twt encoders
This commit is contained in:
commit
7b884ca2f9
76
go.mod
Normal file
76
go.mod
Normal file
@ -0,0 +1,76 @@
|
||||
module go.sour.is/lextwt-encoding
|
||||
|
||||
go 1.24.0
|
||||
|
||||
tool (
|
||||
github.com/Zxilly/go-size-analyzer/cmd/gsa
|
||||
github.com/hamba/avro/v2/cmd/avrogen
|
||||
github.com/hamba/avro/v2/cmd/avrosv
|
||||
google.golang.org/protobuf/cmd/protoc-gen-go
|
||||
)
|
||||
|
||||
require github.com/hamba/avro/v2 v2.28.0
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/writeas/go-strip-markdown/v2 v2.1.1 // indirect
|
||||
go.yarn.social/types v0.0.0-20250108134258-ed75fa653ede // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Zxilly/go-size-analyzer v1.7.7 // indirect
|
||||
github.com/ZxillyFork/gore v0.0.0-20250212071411-56f1a74740b2 // indirect
|
||||
github.com/ZxillyFork/gosym v0.0.0-20240510024817-deed2b882525 // indirect
|
||||
github.com/ZxillyFork/trie v0.0.0-20240512061834-f75150731646 // indirect
|
||||
github.com/alecthomas/kong v1.8.1 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/blacktop/go-dwarf v1.0.10 // indirect
|
||||
github.com/blacktop/go-macho v1.1.238 // indirect
|
||||
github.com/charmbracelet/bubbles v0.20.0 // indirect
|
||||
github.com/charmbracelet/bubbletea v1.3.3 // indirect
|
||||
github.com/charmbracelet/lipgloss v1.0.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.8.0 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||
github.com/go-delve/delve v1.24.0 // indirect
|
||||
github.com/go-json-experiment/json v0.0.0-20250213060926-925ba3f173fa // indirect
|
||||
github.com/hamba/avro v1.8.0
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.6 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/knadh/profiler v0.2.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/nikolaydubina/treemap v1.2.5 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/samber/lo v1.49.1 // indirect
|
||||
github.com/stretchr/testify v1.10.0
|
||||
go.yarn.social/lextwt v0.1.2
|
||||
golang.org/x/arch v0.14.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
)
|
142
go.sum
Normal file
142
go.sum
Normal file
@ -0,0 +1,142 @@
|
||||
github.com/Zxilly/go-size-analyzer v1.7.7 h1:z+OwZgSENyR5EYh2Oce3qvDgC/ghEIwL2cf86ilKkJA=
|
||||
github.com/Zxilly/go-size-analyzer v1.7.7/go.mod h1:zanxPHgC5cVqi9D2l3X6Up9cfSePAVFUn8Bnoixf05Y=
|
||||
github.com/ZxillyFork/gore v0.0.0-20250212071411-56f1a74740b2 h1:2H4tzbdntoU7JdP096mOIIk/nLoDF+V1xOCvI5JmBic=
|
||||
github.com/ZxillyFork/gore v0.0.0-20250212071411-56f1a74740b2/go.mod h1:sSIhs/qonuXnrcWFzxoAlCwcef2NiWqcrXYjJPP+DXE=
|
||||
github.com/ZxillyFork/gosym v0.0.0-20240510024817-deed2b882525 h1:JtN7QBnRxeyMvDJjVdfjhGHL/msqqapHMG5jPVYh32A=
|
||||
github.com/ZxillyFork/gosym v0.0.0-20240510024817-deed2b882525/go.mod h1:AC2xDL/KBa60pBB/m0zRCDCGvzLrMkmW/aY0q+uThFE=
|
||||
github.com/ZxillyFork/trie v0.0.0-20240512061834-f75150731646 h1:Mkm17zXN+CiAXdV9/7mdCUGuEzlUNu73mB6En++kUkE=
|
||||
github.com/ZxillyFork/trie v0.0.0-20240512061834-f75150731646/go.mod h1:wbU6+GbSHDwVSMpzFyOVrX/WdFHXH4j7j8Rg8rbyo+4=
|
||||
github.com/alecthomas/kong v1.8.1 h1:6aamvWBE/REnR/BCq10EcozmcpUPc5aGI1lPAWdB0EE=
|
||||
github.com/alecthomas/kong v1.8.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/blacktop/go-dwarf v1.0.10 h1:i9zYgcIROETsNZ6V+zZn3uDH21FCG5BLLZ837GitxS0=
|
||||
github.com/blacktop/go-dwarf v1.0.10/go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo=
|
||||
github.com/blacktop/go-macho v1.1.238 h1:OFfT6NB/SWxkoky7L/ytuY8QekgFpa9pmz/GHUQLsmM=
|
||||
github.com/blacktop/go-macho v1.1.238/go.mod h1:dtlW2AJKQpFzImBVPWiUKZ6OxrQ2MLfWi/BPPe0EONE=
|
||||
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
|
||||
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
|
||||
github.com/charmbracelet/bubbletea v1.3.3 h1:WpU6fCY0J2vDWM3zfS3vIDi/ULq3SYphZhkAGGvmEUY=
|
||||
github.com/charmbracelet/bubbletea v1.3.3/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo=
|
||||
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
|
||||
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
|
||||
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
|
||||
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
||||
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
|
||||
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
|
||||
github.com/go-delve/delve v1.24.0 h1:M1auuI7kyfXZm5LMDQEqhqr4koKWOzGKhCgwMxsLQfo=
|
||||
github.com/go-delve/delve v1.24.0/go.mod h1:yNWXOuo4yslMOOj7O8gIRrf/trDBrFy5ZXwJL4ZzOos=
|
||||
github.com/go-json-experiment/json v0.0.0-20250213060926-925ba3f173fa h1:Rpu6sKAzIeSWBkrFHD52g8yipagcPbY2Lmm70NL1Gzc=
|
||||
github.com/go-json-experiment/json v0.0.0-20250213060926-925ba3f173fa/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/hamba/avro v1.8.0 h1:eCVrLX7UYThA3R3yBZ+rpmafA5qTc3ZjpTz6gYJoVGU=
|
||||
github.com/hamba/avro v1.8.0/go.mod h1:NiGUcrLLT+CKfGu5REWQtD9OVPPYUGMVFiC+DE0lQfY=
|
||||
github.com/hamba/avro/v2 v2.28.0 h1:E8J5D27biyAulWKNiEBhV85QPc9xRMCUCGJewS0KYCE=
|
||||
github.com/hamba/avro/v2 v2.28.0/go.mod h1:9TVrlt1cG1kkTUtm9u2eO5Qb7rZXlYzoKqPt8TSH+TA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.6 h1:LyezkL+1SuqH2z47e5IMQkYUIcs2BD+MnpdPRiRcN0c=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.6/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/knadh/profiler v0.2.0 h1:jaY0xlQs8iaWxKdvGHOftaZnX7d8l7yrCGQPSecwnng=
|
||||
github.com/knadh/profiler v0.2.0/go.mod h1:LqNkAu++MfFkbEDA63AmRaIf6UkGrLXyZ5VQQdekZiI=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
|
||||
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
|
||||
github.com/nikolaydubina/treemap v1.2.5 h1:oSC5z/qnsGLbkU2IihSrh2pS7uDjUq7ipGj8aw8bfII=
|
||||
github.com/nikolaydubina/treemap v1.2.5/go.mod h1:8+wLGh917AyeJqBN1D5KM26tv6W/XfvsY+nfJd04/u8=
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/writeas/go-strip-markdown/v2 v2.1.1 h1:hAxUM21Uhznf/FnbVGiJciqzska6iLei22Ijc3q2e28=
|
||||
github.com/writeas/go-strip-markdown/v2 v2.1.1/go.mod h1:UvvgPJgn1vvN8nWuE5e7v/+qmDu3BSVnKAB6Gl7hFzA=
|
||||
go.yarn.social/lextwt v0.1.1 h1:afyIZGvHBOZ81LD1OVg9wzP032+9sEihEHX7IdHkkPg=
|
||||
go.yarn.social/lextwt v0.1.1/go.mod h1:JOPCOh+3bHv+BMaFZpKzw6soiXbIlZD5b2f7YKDDjqk=
|
||||
go.yarn.social/lextwt v0.1.2 h1:hQYWMJmH2ziKsbFtqpf1eylGKq+CDSeQNtRW3rYL+kM=
|
||||
go.yarn.social/lextwt v0.1.2/go.mod h1:JOPCOh+3bHv+BMaFZpKzw6soiXbIlZD5b2f7YKDDjqk=
|
||||
go.yarn.social/types v0.0.0-20250108134258-ed75fa653ede h1:XV9tuDQ605xxH4qIQPRHM1bOa7k0rJZ2RqA5kz2Nun4=
|
||||
go.yarn.social/types v0.0.0-20250108134258-ed75fa653ede/go.mod h1:+xnDkQ0T0S8emxWIsvxlCAoyF8gBaj0q81hr/VrKc0c=
|
||||
golang.org/x/arch v0.14.0 h1:z9JUEZWr8x4rR0OU6c4/4t6E6jOZ8/QBS2bBYBm4tx4=
|
||||
golang.org/x/arch v0.14.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs=
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo=
|
||||
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
|
||||
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
|
||||
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
166
lextwt.avro
Normal file
166
lextwt.avro
Normal file
@ -0,0 +1,166 @@
|
||||
{
|
||||
"type": "record",
|
||||
"name": "lextwt",
|
||||
"namespace": "social.yarn.lextwt",
|
||||
"fields": [
|
||||
{
|
||||
"name": "nick",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "uri",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "created",
|
||||
"type": "long",
|
||||
"logicalType": "timestamp-millis"
|
||||
},
|
||||
{
|
||||
"name": "createdZone",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "createdOffset",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"name": "msg",
|
||||
"type": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"name": "elem",
|
||||
"type": [
|
||||
"null",
|
||||
"string",
|
||||
{
|
||||
"type": "record",
|
||||
"name": "linesep",
|
||||
"fields": []
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "comment",
|
||||
"fields": [
|
||||
{
|
||||
"name": "comment",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "key",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "mention",
|
||||
"fields": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "bangmention",
|
||||
"fields": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "hashtag",
|
||||
"fields": [
|
||||
{
|
||||
"name": "tag",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "subject",
|
||||
"fields": [
|
||||
{
|
||||
"name": "subject",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "tag",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "link",
|
||||
"fields": [
|
||||
{
|
||||
"name": "linkType",
|
||||
"type": "int",
|
||||
"logicalType": "int8"
|
||||
},
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "record",
|
||||
"name": "code",
|
||||
"fields": [
|
||||
{
|
||||
"name": "code",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "codetype",
|
||||
"type": "int",
|
||||
"logicalType": "int8"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
1
lextwt.proto
Normal file
1
lextwt.proto
Normal file
@ -0,0 +1 @@
|
||||
option go_package = "go.sour.is/lextwt-proto/pb";
|
220
twt-avro/gen.go
Normal file
220
twt-avro/gen.go
Normal file
@ -0,0 +1,220 @@
|
||||
// Code generated by avro/gen. DO NOT EDIT.
|
||||
package twt_avro
|
||||
|
||||
import (
|
||||
"github.com/hamba/avro/v2"
|
||||
)
|
||||
|
||||
// Linesep is a generated struct.
|
||||
type Linesep struct {
|
||||
}
|
||||
|
||||
var schemaLinesep = avro.MustParse(`{"name":"social.yarn.lextwt.linesep","type":"record","fields":[]}`)
|
||||
|
||||
// Schema returns the schema for Linesep.
|
||||
func (o *Linesep) Schema() avro.Schema {
|
||||
return schemaLinesep
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Linesep) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Linesep) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Comment is a generated struct.
|
||||
type Comment struct {
|
||||
Comment string `avro:"comment"`
|
||||
Key string `avro:"key"`
|
||||
Value string `avro:"value"`
|
||||
}
|
||||
|
||||
var schemaComment = avro.MustParse(`{"name":"social.yarn.lextwt.comment","type":"record","fields":[{"name":"comment","type":"string"},{"name":"key","type":"string"},{"name":"value","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Comment.
|
||||
func (o *Comment) Schema() avro.Schema {
|
||||
return schemaComment
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Comment) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Comment) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Mention is a generated struct.
|
||||
type Mention struct {
|
||||
Name string `avro:"name"`
|
||||
Domain string `avro:"domain"`
|
||||
Target string `avro:"target"`
|
||||
}
|
||||
|
||||
var schemaMention = avro.MustParse(`{"name":"social.yarn.lextwt.mention","type":"record","fields":[{"name":"name","type":"string"},{"name":"domain","type":"string"},{"name":"target","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Mention.
|
||||
func (o *Mention) Schema() avro.Schema {
|
||||
return schemaMention
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Mention) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Mention) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Bangmention is a generated struct.
|
||||
type Bangmention struct {
|
||||
Name string `avro:"name"`
|
||||
Target string `avro:"target"`
|
||||
}
|
||||
|
||||
var schemaBangmention = avro.MustParse(`{"name":"social.yarn.lextwt.bangmention","type":"record","fields":[{"name":"name","type":"string"},{"name":"target","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Bangmention.
|
||||
func (o *Bangmention) Schema() avro.Schema {
|
||||
return schemaBangmention
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Bangmention) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Bangmention) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Hashtag is a generated struct.
|
||||
type Hashtag struct {
|
||||
Tag string `avro:"tag"`
|
||||
Target string `avro:"target"`
|
||||
}
|
||||
|
||||
var schemaHashtag = avro.MustParse(`{"name":"social.yarn.lextwt.hashtag","type":"record","fields":[{"name":"tag","type":"string"},{"name":"target","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Hashtag.
|
||||
func (o *Hashtag) Schema() avro.Schema {
|
||||
return schemaHashtag
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Hashtag) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Hashtag) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Subject is a generated struct.
|
||||
type Subject struct {
|
||||
Subject string `avro:"subject"`
|
||||
Tag string `avro:"tag"`
|
||||
Target string `avro:"target"`
|
||||
}
|
||||
|
||||
var schemaSubject = avro.MustParse(`{"name":"social.yarn.lextwt.subject","type":"record","fields":[{"name":"subject","type":"string"},{"name":"tag","type":"string"},{"name":"target","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Subject.
|
||||
func (o *Subject) Schema() avro.Schema {
|
||||
return schemaSubject
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Subject) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Subject) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Link is a generated struct.
|
||||
type Link struct {
|
||||
LinkType int `avro:"linkType"`
|
||||
Text string `avro:"text"`
|
||||
Target string `avro:"target"`
|
||||
Title string `avro:"title"`
|
||||
}
|
||||
|
||||
var schemaLink = avro.MustParse(`{"name":"social.yarn.lextwt.link","type":"record","fields":[{"name":"linkType","type":"int"},{"name":"text","type":"string"},{"name":"target","type":"string"},{"name":"title","type":"string"}]}`)
|
||||
|
||||
// Schema returns the schema for Link.
|
||||
func (o *Link) Schema() avro.Schema {
|
||||
return schemaLink
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Link) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Link) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Code is a generated struct.
|
||||
type Code struct {
|
||||
Code string `avro:"code"`
|
||||
Codetype int `avro:"codetype"`
|
||||
}
|
||||
|
||||
var schemaCode = avro.MustParse(`{"name":"social.yarn.lextwt.code","type":"record","fields":[{"name":"code","type":"string"},{"name":"codetype","type":"int"}]}`)
|
||||
|
||||
// Schema returns the schema for Code.
|
||||
func (o *Code) Schema() avro.Schema {
|
||||
return schemaCode
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Code) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Code) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
||||
|
||||
// Lextwt is a generated struct.
|
||||
type Lextwt struct {
|
||||
Nick string `avro:"nick"`
|
||||
URI string `avro:"uri"`
|
||||
Created int64 `avro:"created"`
|
||||
CreatedZone string `avro:"createdZone"`
|
||||
CreatedOffset int `avro:"createdOffset"`
|
||||
Msg []any `avro:"msg"`
|
||||
}
|
||||
|
||||
var schemaLextwt = avro.MustParse(`{"name":"social.yarn.lextwt.lextwt","type":"record","fields":[{"name":"nick","type":"string"},{"name":"uri","type":"string"},{"name":"created","type":"long"},{"name":"createdZone","type":"string"},{"name":"createdOffset","type":"int"},{"name":"msg","type":{"type":"array","items":["null","string",{"name":"social.yarn.lextwt.linesep","type":"record","fields":[]},{"name":"social.yarn.lextwt.comment","type":"record","fields":[{"name":"comment","type":"string"},{"name":"key","type":"string"},{"name":"value","type":"string"}]},{"name":"social.yarn.lextwt.mention","type":"record","fields":[{"name":"name","type":"string"},{"name":"domain","type":"string"},{"name":"target","type":"string"}]},{"name":"social.yarn.lextwt.bangmention","type":"record","fields":[{"name":"name","type":"string"},{"name":"target","type":"string"}]},{"name":"social.yarn.lextwt.hashtag","type":"record","fields":[{"name":"tag","type":"string"},{"name":"target","type":"string"}]},{"name":"social.yarn.lextwt.subject","type":"record","fields":[{"name":"subject","type":"string"},{"name":"tag","type":"string"},{"name":"target","type":"string"}]},{"name":"social.yarn.lextwt.link","type":"record","fields":[{"name":"linkType","type":"int"},{"name":"text","type":"string"},{"name":"target","type":"string"},{"name":"title","type":"string"}]},{"name":"social.yarn.lextwt.code","type":"record","fields":[{"name":"code","type":"string"},{"name":"codetype","type":"int"}]}]}}]}`)
|
||||
|
||||
// Schema returns the schema for Lextwt.
|
||||
func (o *Lextwt) Schema() avro.Schema {
|
||||
return schemaLextwt
|
||||
}
|
||||
|
||||
// Unmarshal decodes b into the receiver.
|
||||
func (o *Lextwt) Unmarshal(b []byte) error {
|
||||
return avro.Unmarshal(o.Schema(), b, o)
|
||||
}
|
||||
|
||||
// Marshal encodes the receiver.
|
||||
func (o *Lextwt) Marshal() ([]byte, error) {
|
||||
return avro.Marshal(o.Schema(), o)
|
||||
}
|
215
twt-avro/helper.go
Normal file
215
twt-avro/helper.go
Normal file
@ -0,0 +1,215 @@
|
||||
package twt_avro
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/hamba/avro"
|
||||
"go.yarn.social/lextwt"
|
||||
"go.yarn.social/types"
|
||||
)
|
||||
|
||||
const (
|
||||
keySubject = "social.yarn.lextwt.subject"
|
||||
keyCode = "social.yarn.lextwt.code"
|
||||
keyMention = "social.yarn.lextwt.mention"
|
||||
keyHashtag = "social.yarn.lextwt.hashtag"
|
||||
keyLink = "social.yarn.lextwt.link"
|
||||
keyBangmention = "social.yarn.lextwt.bangmention"
|
||||
keyLinesep = "social.yarn.lextwt.linesep"
|
||||
keyComment = "social.yarn.lextwt.comment"
|
||||
keyText = "social.yarn.lextwt.text"
|
||||
)
|
||||
|
||||
func Register() {
|
||||
avro.Register(keyText, "")
|
||||
avro.Register(keySubject, Subject{})
|
||||
avro.Register(keyCode, Code{})
|
||||
avro.Register(keyMention, Mention{})
|
||||
avro.Register(keyHashtag, Hashtag{})
|
||||
avro.Register(keyLink, Link{})
|
||||
avro.Register(keyBangmention, Bangmention{})
|
||||
avro.Register(keyLinesep, Linesep{})
|
||||
avro.Register(keyComment, Comment{})
|
||||
}
|
||||
|
||||
func Elem(o any) any {
|
||||
key := "unknown"
|
||||
switch o.(type) {
|
||||
case Subject:
|
||||
key = keySubject
|
||||
case Code:
|
||||
key = keyCode
|
||||
case Mention:
|
||||
key = keyMention
|
||||
case Hashtag:
|
||||
key = keyHashtag
|
||||
case Link:
|
||||
key = keyLink
|
||||
case Bangmention:
|
||||
key = keyBangmention
|
||||
case Linesep:
|
||||
key = keyLinesep
|
||||
case Comment:
|
||||
key = keyComment
|
||||
case string:
|
||||
return o
|
||||
}
|
||||
|
||||
return map[string]any{key: o}
|
||||
}
|
||||
|
||||
func Msg(items ...any) []any {
|
||||
return items
|
||||
}
|
||||
|
||||
func FromTwt(twt types.Twt) Lextwt {
|
||||
return FromLextwt(twt.(*lextwt.Twt))
|
||||
}
|
||||
|
||||
func FromLextwt(twt *lextwt.Twt) Lextwt {
|
||||
if twt == nil {
|
||||
return Lextwt{}
|
||||
}
|
||||
|
||||
ts := twt.Created()
|
||||
_, offset := ts.Zone()
|
||||
l := Lextwt{
|
||||
Nick: twt.Twter().Nick,
|
||||
URI: twt.Twter().URI,
|
||||
Created: ts.UnixMilli(),
|
||||
CreatedOffset: offset,
|
||||
CreatedZone: "",
|
||||
}
|
||||
|
||||
for _, e := range twt.Elems() {
|
||||
if e == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if e == lextwt.LineSeparator {
|
||||
l.Msg = append(l.Msg, Elem(Linesep{}))
|
||||
continue
|
||||
}
|
||||
|
||||
switch e := e.(type) {
|
||||
case *lextwt.Subject:
|
||||
l.Msg = append(l.Msg, Elem(Subject{Subject: e.Subject(), Tag: e.Tag().Text(), Target: e.Tag().Target()}))
|
||||
case *lextwt.Code:
|
||||
l.Msg = append(l.Msg, Elem(Code{Code: e.Text()}))
|
||||
case *lextwt.Mention:
|
||||
l.Msg = append(l.Msg, Elem(Mention{Name: e.Name(), Domain: e.Domain(), Target: e.Target()}))
|
||||
case *lextwt.Tag:
|
||||
l.Msg = append(l.Msg, Elem(Hashtag{Tag: e.Text(), Target: e.Target()}))
|
||||
case *lextwt.Link:
|
||||
l.Msg = append(l.Msg, Elem(Link{LinkType: int(e.LinkType()), Text: e.Text(), Target: e.Target(), Title: e.Title()}))
|
||||
case *lextwt.BangMention:
|
||||
l.Msg = append(l.Msg, Elem(Bangmention{Name: e.Name(), Target: e.Target()}))
|
||||
case *lextwt.Comment:
|
||||
l.Msg = append(l.Msg, Elem(Comment{Comment: e.Text(), Key: e.Key(), Value: e.Value()}))
|
||||
case *lextwt.Text:
|
||||
l.Msg = append(l.Msg, Elem(e.Literal()))
|
||||
}
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
func (l Lextwt) ToTwt() types.Twt {
|
||||
return l.ToLextwt()
|
||||
}
|
||||
|
||||
func (lx Lextwt) ToLextwt() *lextwt.Twt {
|
||||
twter := types.Twter{
|
||||
Nick: lx.Nick,
|
||||
URI: lx.URI,
|
||||
}
|
||||
|
||||
ts := time.UnixMilli(lx.Created)
|
||||
|
||||
if tz := time.FixedZone(lx.CreatedZone, lx.CreatedOffset); tz != nil {
|
||||
ts = ts.In(tz)
|
||||
}
|
||||
dt := lextwt.NewDateTime(ts, ts.Format(time.RFC3339))
|
||||
|
||||
elems := make([]lextwt.Elem, 0, len(lx.Msg))
|
||||
|
||||
for _, e := range lx.Msg {
|
||||
|
||||
switch e := e.(type) {
|
||||
case map[string]any:
|
||||
if text, ok := e["string"].(string); ok {
|
||||
elems = append(elems, lextwt.NewText(text))
|
||||
}
|
||||
|
||||
if e, ok := e[keySubject].(map[string]any); ok {
|
||||
subject := read[string](e, "subject")
|
||||
tag := read[string](e, "tag")
|
||||
target := read[string](e, "target")
|
||||
|
||||
if subject == "" {
|
||||
elems = append(elems, lextwt.NewSubjectTag(tag, target))
|
||||
} else {
|
||||
elems = append(elems, lextwt.NewSubject(subject))
|
||||
}
|
||||
}
|
||||
|
||||
if m, ok := e[keyCode].(map[string]any); ok {
|
||||
code := read[string](m, "code")
|
||||
codeType := lextwt.CodeType(read[int8](m, "codetype"))
|
||||
elems = append(elems, lextwt.NewCode(code, codeType))
|
||||
}
|
||||
|
||||
if e, ok := e[keyMention].(map[string]any); ok {
|
||||
name := read[string](e, "name")
|
||||
target := read[string](e, "target")
|
||||
elems = append(elems, lextwt.NewMention(name, target))
|
||||
}
|
||||
|
||||
if e, ok := e[keyHashtag].(map[string]any); ok {
|
||||
tag := read[string](e, "tag")
|
||||
target := read[string](e, "target")
|
||||
elems = append(elems, lextwt.NewTag(tag, target))
|
||||
}
|
||||
|
||||
if e, ok := e[keyLink].(map[string]any); ok {
|
||||
text := read[string](e, "text")
|
||||
target := read[string](e, "target")
|
||||
linkType := lextwt.LinkType(read[int](e, "linkType"))
|
||||
elems = append(elems, lextwt.NewLink(text, target, linkType))
|
||||
}
|
||||
|
||||
if e, ok := e[keyBangmention].(map[string]any); ok {
|
||||
name := read[string](e, "name")
|
||||
target := read[string](e, "target")
|
||||
elems = append(elems, lextwt.NewBangMention(name, target))
|
||||
}
|
||||
|
||||
if e, ok := e[keyComment].(map[string]any); ok {
|
||||
comment := read[string](e, "comment")
|
||||
key := read[string](e, "key")
|
||||
value := read[string](e, "value")
|
||||
|
||||
if key != "" {
|
||||
elems = append(elems, lextwt.NewCommentValue(comment, key, value))
|
||||
} else {
|
||||
elems = append(elems, lextwt.NewComment(comment))
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := e[keyLinesep].(map[string]any); ok {
|
||||
elems = append(elems, lextwt.LineSeparator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lextwt.NewTwt(twter, dt, elems...)
|
||||
}
|
||||
|
||||
func read[T any](m map[string]any, k string) T {
|
||||
val, ok := m[k].(T)
|
||||
if !ok {
|
||||
var zero T
|
||||
return zero
|
||||
}
|
||||
return val
|
||||
}
|
115
twt-avro/helper_test.go
Normal file
115
twt-avro/helper_test.go
Normal file
@ -0,0 +1,115 @@
|
||||
package twt_avro_test
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
twt_avro "go.sour.is/lextwt-encoding/twt-avro"
|
||||
"go.yarn.social/lextwt"
|
||||
"go.yarn.social/types"
|
||||
)
|
||||
|
||||
func TestMarshal(t *testing.T) {
|
||||
twt_avro.Register()
|
||||
|
||||
ts := must(time.Parse(time.RFC3339, "2021-01-24T02:19:54Z"))
|
||||
zone, offset := ts.Zone()
|
||||
in := twt_avro.Lextwt{
|
||||
Nick: "xuu",
|
||||
URI: "https://xuu.txt",
|
||||
Created: ts.UnixMilli(),
|
||||
CreatedZone: zone,
|
||||
CreatedOffset: offset,
|
||||
Msg: twt_avro.Msg(
|
||||
twt_avro.Elem(twt_avro.Subject{
|
||||
Subject: "foobar",
|
||||
}),
|
||||
twt_avro.Elem("foo"),
|
||||
twt_avro.Elem(twt_avro.Code{
|
||||
Code: "baz",
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
||||
data, err := in.Marshal()
|
||||
if err != nil {
|
||||
log.Fatal("marshal: ", err)
|
||||
}
|
||||
|
||||
fmt.Println(data)
|
||||
// Outputs: [54 6 102 111 111]
|
||||
|
||||
out := twt_avro.Lextwt{}
|
||||
err = out.Unmarshal(data)
|
||||
if err != nil {
|
||||
log.Fatal("unmarshal: ", err)
|
||||
}
|
||||
|
||||
fmt.Printf("%#v", out)
|
||||
// Outputs: {27 foo}
|
||||
}
|
||||
|
||||
func must[T any](t T, err error) T {
|
||||
if err != nil {
|
||||
var zero T
|
||||
return zero
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func TestFromTwt(t *testing.T) {
|
||||
twt_avro.Register()
|
||||
|
||||
tests := []struct {
|
||||
in string
|
||||
twter *types.Twter
|
||||
}{
|
||||
{
|
||||
in: "2021-01-24T02:19:54-07:00 (#asdf1234) @xuu This is a `twt`!\u2028Next Line!",
|
||||
twter: &types.Twter{Nick: "xuu@sour.is", URI: "https://xuu.txt"},
|
||||
},
|
||||
{
|
||||
in: "2021-01-24T02:19:54-07:00 !xuu <https://xuu.txt> #lol [lang=en]",
|
||||
twter: &types.Twter{Nick: "xuu@sour.is", URI: "https://xuu.txt"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
twt, err := lextwt.ParseLine(test.in, test.twter)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
av := twt_avro.FromTwt(twt)
|
||||
|
||||
b, err := av.Marshal()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
t.Log(enc(b))
|
||||
|
||||
out := twt_avro.Lextwt{}
|
||||
err = out.Unmarshal(b)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
t.Log(spew.Sdump(out))
|
||||
|
||||
outlx := out.ToLextwt()
|
||||
|
||||
outText := fmt.Sprintf("%+l",outlx)
|
||||
t.Log(outText)
|
||||
if outText != test.in {
|
||||
t.Errorf("\nexpected %s\n got %s", test.in, outText)
|
||||
}
|
||||
t.Log(spew.Sdump(outlx.Elems()))
|
||||
}
|
||||
}
|
||||
|
||||
var enc = base64.RawStdEncoding.EncodeToString
|
Loading…
x
Reference in New Issue
Block a user