time: don't depend on the io package
The time package has never depended on the io package until
a recent change during Go 1.7 to use the io.Seek* constants.
The go/build dependency check didn't catch this because "time" was
allowed to depend on meta package group "L0", which included "io".
Adding the "io" package broke one of Dmitry's tools. The tool is
fixable, but it's also not necessary for us to depend on "io" at all
for some constants. Mirror the constants instead, and change
deps_test.go to prevent an io dependency in the future.
Change-Id: I74325228565279a74fa4a2f419643f5710e3e09f
Reviewed-on: https://go-review.googlesource.com/22960
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index 8a8c4be2..d0d4fbb 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -136,7 +136,19 @@
"internal/syscall/unix": {"L0", "syscall"},
"internal/syscall/windows": {"L0", "syscall", "internal/syscall/windows/sysdll"},
"internal/syscall/windows/registry": {"L0", "syscall", "internal/syscall/windows/sysdll", "unicode/utf16"},
- "time": {"L0", "syscall", "internal/syscall/windows/registry"},
+ "time": {
+ // "L0" without the "io" package:
+ "errors",
+ "runtime",
+ "runtime/internal/atomic",
+ "sync",
+ "sync/atomic",
+ "unsafe",
+ // Other time dependencies:
+ "internal/syscall/windows/registry",
+ "syscall",
+ },
+
"os": {"L1", "os", "syscall", "time", "internal/syscall/windows"},
"path/filepath": {"L2", "os", "syscall"},
"io/ioutil": {"L2", "os", "path/filepath", "time"},
diff --git a/src/time/sys_plan9.go b/src/time/sys_plan9.go
index 507d115..11365a7 100644
--- a/src/time/sys_plan9.go
+++ b/src/time/sys_plan9.go
@@ -8,7 +8,6 @@
import (
"errors"
- "io"
"syscall"
)
@@ -56,9 +55,9 @@
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := io.SeekStart
+ whence := seekStart
if off < 0 {
- whence = io.SeekEnd
+ whence = seekEnd
}
if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
return err
diff --git a/src/time/sys_unix.go b/src/time/sys_unix.go
index dea03e0..91d54c9 100644
--- a/src/time/sys_unix.go
+++ b/src/time/sys_unix.go
@@ -8,7 +8,6 @@
import (
"errors"
- "io"
"syscall"
)
@@ -56,9 +55,9 @@
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := io.SeekStart
+ whence := seekStart
if off < 0 {
- whence = io.SeekEnd
+ whence = seekEnd
}
if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
return err
diff --git a/src/time/sys_windows.go b/src/time/sys_windows.go
index 4f41b1a..a4a068f 100644
--- a/src/time/sys_windows.go
+++ b/src/time/sys_windows.go
@@ -6,7 +6,6 @@
import (
"errors"
- "io"
"syscall"
)
@@ -53,9 +52,9 @@
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := io.SeekStart
+ whence := seekStart
if off < 0 {
- whence = io.SeekEnd
+ whence = seekEnd
}
if _, err := syscall.Seek(syscall.Handle(fd), int64(off), whence); err != nil {
return err
diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go
index 66777f6..19cd40d 100644
--- a/src/time/zoneinfo_read.go
+++ b/src/time/zoneinfo_read.go
@@ -11,6 +11,13 @@
import "errors"
+// Copies of io.Seek* constants to avoid importing "io":
+const (
+ seekStart = 0
+ seekCurrent = 1
+ seekEnd = 2
+)
+
// Simple I/O interface to binary blob of data.
type data struct {
p []byte