This commit is contained in:
Jeff Carr 2025-08-21 01:12:13 -05:00
parent 0831f1f292
commit 0d568e2674
5 changed files with 38 additions and 6 deletions

View File

@ -6,3 +6,9 @@ chat.pb.go: chat.proto
makechat: makechat:
GO111MODULE=off go run make_chat.go GO111MODULE=off go run make_chat.go
parselog:
GO111MODULE=off go run parse_protobuf_log.go
goimports:
goimports -w *.go

View File

@ -1,5 +1,3 @@
GO111MODULE=off go run make_chat.go
trying...
uuid: "9fd31f10-c25d-4d66-bc8d-5f6eb7c79057" uuid: "9fd31f10-c25d-4d66-bc8d-5f6eb7c79057"
version: "v0.0.1 go.wit.com/lib/protobuf/chatpb" version: "v0.0.1 go.wit.com/lib/protobuf/chatpb"
Chats: { Chats: {
@ -25,6 +23,10 @@ Chats: {
} }
Chats: { Chats: {
from: GEMINI from: GEMINI
ctime: {
seconds: 1755755745
nanos: 136202653
}
content: "funny" content: "funny"
} }
Chats: { Chats: {
@ -33,6 +35,9 @@ Chats: {
} }
Chats: { Chats: {
from: GEMINI from: GEMINI
ctime: {
seconds: 1755755745
nanos: 136202987
}
content: "I like astronomy" content: "I like astronomy"
} }

View File

@ -1,7 +1,9 @@
package main package main
import "go.wit.com/log" import (
import "go.wit.com/lib/protobuf/chatpb" "go.wit.com/lib/protobuf/chatpb"
"go.wit.com/log"
)
func main() { func main() {
log.Info("trying...") log.Info("trying...")

20
parse_protobuf_log.go Normal file
View File

@ -0,0 +1,20 @@
package main
import (
"os"
"go.wit.com/lib/protobuf/chatpb"
"go.wit.com/log"
)
func main() {
data, _ := os.ReadFile("log/sample.text")
log.Info("trying unmarshal len(data) =", len(data))
pb, err := chatpb.UnmarshalChats(data)
if err != nil {
log.Info("Unmarshal error", err)
return
}
log.Info(pb.FormatTEXT())
}

View File

@ -28,4 +28,3 @@ func main() {
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
} }
} }