diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 08cb18f207a4..44321a1fed86 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -723,8 +723,6 @@ func TestLint(t *testing.T) { "--", "*.go", ":!**/embedded.go", - ":!util/timeutil/now_unix.go", - ":!util/timeutil/now_windows.go", ":!util/timeutil/time.go", ":!util/timeutil/zoneinfo.go", ":!util/tracing/span.go", diff --git a/pkg/util/timeutil/BUILD.bazel b/pkg/util/timeutil/BUILD.bazel index 9c7b34e8414c..71cf93609cab 100644 --- a/pkg/util/timeutil/BUILD.bazel +++ b/pkg/util/timeutil/BUILD.bazel @@ -4,8 +4,6 @@ go_library( name = "timeutil", srcs = [ "manual_time.go", - "now_unix.go", - "now_windows.go", "stopwatch.go", "time.go", "time_source.go", @@ -20,12 +18,7 @@ go_library( deps = [ "//pkg/util/syncutil", "@com_github_cockroachdb_errors//:errors", - ] + select({ - "@io_bazel_rules_go//go/platform:windows": [ - "@org_golang_x_sys//windows", - ], - "//conditions:default": [], - }), + ], ) go_test( diff --git a/pkg/util/timeutil/now_unix.go b/pkg/util/timeutil/now_unix.go deleted file mode 100644 index 085a02688332..000000000000 --- a/pkg/util/timeutil/now_unix.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -//go:build !windows -// +build !windows - -package timeutil - -import "time" - -// Now returns the current UTC time. -func Now() time.Time { - return time.Now().UTC() -} diff --git a/pkg/util/timeutil/now_windows.go b/pkg/util/timeutil/now_windows.go deleted file mode 100644 index 1f1aac378cca..000000000000 --- a/pkg/util/timeutil/now_windows.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2017 The Cockroach Authors. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -package timeutil - -import ( - "time" - - "github.com/cockroachdb/errors" - "golang.org/x/sys/windows" -) - -func init() { - if err := windows.LoadGetSystemTimePreciseAsFileTime(); err != nil { - panic(errors.Wrap(err, "CockroachDB requires Windows 8 or higher")) - } -} - -// Now returns the current UTC time. -// -// This has a higher precision than time.Now in go1.8, but is much slower -// (~2000x) and requires Windows 8+. -// -// TODO(tamird): consider removing this in go1.9. go1.9 is expected to add -// monotonic clock support to values retured from time.Now, which this -// implementation will not support. The monotonic clock support may also -// obviate the need for this, since we only need the higher precision when -// subtracting `time.Time`s. -func Now() time.Time { - var ft windows.Filetime - windows.GetSystemTimePreciseAsFileTime(&ft) - return time.Unix(0, ft.Nanoseconds()).UTC() -} diff --git a/pkg/util/timeutil/time.go b/pkg/util/timeutil/time.go index b94adec1bff0..92600768f147 100644 --- a/pkg/util/timeutil/time.go +++ b/pkg/util/timeutil/time.go @@ -18,6 +18,11 @@ import ( // LibPQTimePrefix is the prefix lib/pq prints time-type datatypes with. const LibPQTimePrefix = "0000-01-01" +// Now returns the current UTC time. +func Now() time.Time { + return time.Now().UTC() +} + // Since returns the time elapsed since t. // It is shorthand for Now().Sub(t). func Since(t time.Time) time.Duration {