summaryrefslogtreecommitdiff
path: root/table.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-16 17:35:38 -0500
committerJeff Carr <[email protected]>2025-09-16 17:35:38 -0500
commit7607378bae2f4e10cdd8f44ee534de725fef293b (patch)
tree168b1730a9b6256f2b0c4e6733cf2ad8e4b9265d /table.go
parentb644b03769fb78bdef07612985317e3233d4e7a6 (diff)
more converting to use of 'any'v0.22.36
Diffstat (limited to 'table.go')
-rw-r--r--table.go66
1 files changed, 46 insertions, 20 deletions
diff --git a/table.go b/table.go
index 63647c0..76e2f88 100644
--- a/table.go
+++ b/table.go
@@ -318,27 +318,27 @@ func (me *TreeInfo) addTableCol(t *guipb.Table, grid *Node, name string, w int)
return true
}
- for _, r := range t.AnyCols {
- if name != r.Header.Name {
+ for _, col := range t.AnyCols {
+ if name != col.Header.Name {
// log.Info("skip sint row:", r.Header.Name, "!=", name)
continue
}
// log.Info("tree: Add()ing to grid here", r.Header.Id, r.Header.Name, w, h)
- head := grid.makeGridLabel(r.Header, w, h)
+ head := grid.makeGridLabel(col.Header, w, h)
me.Add(head)
h += 1
- for _, widg := range r.Widgets {
+ for _, widg := range col.Widgets {
msg, err := anypb.UnmarshalNew(widg.Val, proto.UnmarshalOptions{})
if err != nil {
log.Fatalf("failed to unmarshal: %v", err)
}
/*
- var stringValue wrapperspb.StringValue
- if err := msg.UnmarshalTo(&stringValue); err == nil {
- // It's a string, now convert it back to a native Go string
- goString := stringValue.GetValue()
- fmt.Printf("Successfully unpacked string: %s\n", goString)
- }
+ var stringValue wrapperspb.StringValue
+ if err := msg.UnmarshalTo(&stringValue); err == nil {
+ // It's a string, now convert it back to a native Go string
+ goString := stringValue.GetValue()
+ fmt.Printf("Successfully unpacked string: %s\n", goString)
+ }
*/
switch v := msg.(type) {
@@ -349,19 +349,45 @@ func (me *TreeInfo) addTableCol(t *guipb.Table, grid *Node, name string, w int)
widg.Name = shell.FormatDuration(time.Since(v.AsTime()))
case *wrapperspb.StringValue:
/*
- var stringValue wrapperspb.StringValue
- if err := widg.Val.UnmarshalTo(&stringValue); err == nil {
- // It's a string, now convert it back to a native Go string
- goString := stringValue.GetValue()
- fmt.Printf("Successfully unpacked string: %s\n", goString)
- widg.Name = goString
- } else {
- widg.Name = "notsure"
- }
+ var stringValue wrapperspb.StringValue
+ if err := widg.Val.UnmarshalTo(&stringValue); err == nil {
+ // It's a string, now convert it back to a native Go string
+ goString := stringValue.GetValue()
+ fmt.Printf("Successfully unpacked string: %s\n", goString)
+ widg.Name = goString
+ } else {
+ widg.Name = "notsure"
+ }
*/
widg.Name = v.GetValue()
case *anypb.Any:
- fmt.Printf("found any! %T\n", v)
+ var anyVal *anypb.Any
+ anyVal = msg.(*anypb.Any)
+ switch col.Attr.Type {
+ case guipb.ColAttr_STRING:
+ var stringValue wrapperspb.StringValue
+ if err := anyVal.UnmarshalTo(&stringValue); err == nil {
+ // It's a string, now convert it back to a native Go string
+ goString := stringValue.GetValue()
+ // fmt.Printf("Successfully unpacked string: %s\n", goString)
+ widg.Name = goString
+ } else {
+ widg.Name = "anyVal str err"
+ }
+ case guipb.ColAttr_INT:
+ case guipb.ColAttr_TIME:
+ var tsProto timestamppb.Timestamp
+ if err := anyVal.UnmarshalTo(&tsProto); err == nil {
+ // It's a timestamp, now convert it back to a Go time.Time
+ goTime := tsProto.AsTime()
+ // fmt.Printf("Successfully unpacked timestamp: %v\n", goTime)
+ widg.Name = shell.FormatDuration(time.Since(goTime))
+ } else {
+ widg.Name = "terr"
+ }
+ default:
+ }
+ // fmt.Printf("found any! %T\n", v)
// widg.Name = v.GetValue()
default:
fmt.Printf("Unknown type: %T\n", v)