diff --git a/pkg/tcpip/network/internal/multicast/example_test.go b/pkg/tcpip/network/internal/multicast/example_test.go index 3a8b13581..08a187d35 100644 --- a/pkg/tcpip/network/internal/multicast/example_test.go +++ b/pkg/tcpip/network/internal/multicast/example_test.go @@ -103,7 +103,7 @@ func Example() { panic(fmt.Sprintf("table.GetLastUsedTimestamp(%#v) = (_, false)", routeKey)) } - fmt.Printf("Last used timestamp: %d", timestamp.Nanoseconds()) + fmt.Printf("Last used timestamp: %s", timestamp) // Finally, to remove an installed route, call: if removed := table.RemoveInstalledRoute(routeKey); !removed { diff --git a/pkg/tcpip/network/internal/multicast/route_table_test.go b/pkg/tcpip/network/internal/multicast/route_table_test.go index 08cf9e95c..8a60f93cb 100644 --- a/pkg/tcpip/network/internal/multicast/route_table_test.go +++ b/pkg/tcpip/network/internal/multicast/route_table_test.go @@ -452,8 +452,8 @@ func TestSetLastUsedTimestamp(t *testing.T) { t.Fatalf("got table.GetLastUsedTimestamp(%#v) = (_, false_), want = (_, true)", defaultRouteKey) } - if got, want := timestamp.Nanoseconds(), test.wantLastUsedTime.Nanoseconds(); got != want { - t.Errorf("got table.GetLastUsedTimestamp(%#v) = (%v, _), want (%v, _)", defaultRouteKey, got, want) + if timestamp != test.wantLastUsedTime { + t.Errorf("got table.GetLastUsedTimestamp(%#v) = (%s, _), want = (%s, _)", defaultRouteKey, timestamp, test.wantLastUsedTime) } }) } diff --git a/pkg/tcpip/tcpip.go b/pkg/tcpip/tcpip.go index 11dae0c18..b54930f69 100644 --- a/pkg/tcpip/tcpip.go +++ b/pkg/tcpip/tcpip.go @@ -71,9 +71,9 @@ type MonotonicTime struct { nanoseconds int64 } -// Nanoseconds returns the monotonic time in nanoseconds. -func (mt MonotonicTime) Nanoseconds() int64 { - return mt.nanoseconds +// String implements Stringer. +func (mt MonotonicTime) String() string { + return strconv.FormatInt(mt.nanoseconds, 10) } // Before reports whether the monotonic clock reading mt is before u.