diff options
author | Eyal Soha <eyalsoha@google.com> | 2020-04-15 14:57:56 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-15 14:59:15 -0700 |
commit | 3d3bf9603d9a933b4bf19c38190c583894b75d66 (patch) | |
tree | 006f0eaa75e8b04d8d67e74b0e315b4060024e2d /test/packetimpact/testbench/layers.go | |
parent | ea5b8e9633cd2731bb5656dea523beaf3d643472 (diff) |
Use hex.Dump for Layer.String() of byte slices.
PiperOrigin-RevId: 306726587
Diffstat (limited to 'test/packetimpact/testbench/layers.go')
-rw-r--r-- | test/packetimpact/testbench/layers.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/packetimpact/testbench/layers.go b/test/packetimpact/testbench/layers.go index 1ec94ce17..5ce324f0d 100644 --- a/test/packetimpact/testbench/layers.go +++ b/test/packetimpact/testbench/layers.go @@ -15,6 +15,7 @@ package testbench import ( + "encoding/hex" "fmt" "reflect" "strings" @@ -133,7 +134,12 @@ func stringLayer(l Layer) string { if v.IsNil() { continue } - ret = append(ret, fmt.Sprintf("%s:%v", t.Name, reflect.Indirect(v))) + v = reflect.Indirect(v) + if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 { + ret = append(ret, fmt.Sprintf("%s:\n%v", t.Name, hex.Dump(v.Bytes()))) + } else { + ret = append(ret, fmt.Sprintf("%s:%v", t.Name, v)) + } } return fmt.Sprintf("&%s{%s}", t, strings.Join(ret, " ")) } |