Skip to content

Commit 51fe930

Browse files
committed
timeutil: remove detritus windows Now() implementation
We carried a custom implementation of timeutil.Now() for Windows, to overcome the low precision of Go's impl [1]. It was doing so with an expensive implementation. Having this custom implementation also make it tricky to use stdlib functions like Since(), which internally use the stdlib Now(). The Golang issue has since been fixed. [1] golang/go#8687 Release note: None
1 parent 9968d34 commit 51fe930

File tree

5 files changed

+6
-71
lines changed

5 files changed

+6
-71
lines changed

pkg/testutils/lint/lint_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,6 @@ func TestLint(t *testing.T) {
723723
"--",
724724
"*.go",
725725
":!**/embedded.go",
726-
":!util/timeutil/now_unix.go",
727-
":!util/timeutil/now_windows.go",
728726
":!util/timeutil/time.go",
729727
":!util/timeutil/zoneinfo.go",
730728
":!util/tracing/span.go",

pkg/util/timeutil/BUILD.bazel

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ go_library(
44
name = "timeutil",
55
srcs = [
66
"manual_time.go",
7-
"now_unix.go",
8-
"now_windows.go",
97
"stopwatch.go",
108
"time.go",
119
"time_source.go",
@@ -20,12 +18,7 @@ go_library(
2018
deps = [
2119
"//pkg/util/syncutil",
2220
"@com_github_cockroachdb_errors//:errors",
23-
] + select({
24-
"@io_bazel_rules_go//go/platform:windows": [
25-
"@org_golang_x_sys//windows",
26-
],
27-
"//conditions:default": [],
28-
}),
21+
],
2922
)
3023

3124
go_test(

pkg/util/timeutil/now_unix.go

-21
This file was deleted.

pkg/util/timeutil/now_windows.go

-40
This file was deleted.

pkg/util/timeutil/time.go

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import (
1818
// LibPQTimePrefix is the prefix lib/pq prints time-type datatypes with.
1919
const LibPQTimePrefix = "0000-01-01"
2020

21+
// Now returns the current UTC time.
22+
func Now() time.Time {
23+
return time.Now().UTC()
24+
}
25+
2126
// Since returns the time elapsed since t.
2227
// It is shorthand for Now().Sub(t).
2328
func Since(t time.Time) time.Duration {

0 commit comments

Comments
 (0)