]> Cypherpunks repositories - gostls13.git/commitdiff
time: don't depend on the io package
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 9 May 2016 17:21:11 +0000 (17:21 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 9 May 2016 20:31:47 +0000 (20:31 +0000)
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>
src/go/build/deps_test.go
src/time/sys_plan9.go
src/time/sys_unix.go
src/time/sys_windows.go
src/time/zoneinfo_read.go

index 8a8c4be2174af0dc7946cb3dd14e99b56a9de522..d0d4fbba1629671ef47d657018524a932dcfff4f 100644 (file)
@@ -136,7 +136,19 @@ var pkgDeps = map[string][]string{
        "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"},
index 507d1159cfe9d583bdc41cf660422da73b3b08de..11365a791f7dfc48fd20b6affff042ae566fda37 100644 (file)
@@ -8,7 +8,6 @@ package time
 
 import (
        "errors"
-       "io"
        "syscall"
 )
 
@@ -56,9 +55,9 @@ func closefd(fd uintptr) {
 }
 
 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
index dea03e06d51cf985afd805e0727684b28c0b6c34..91d54c9ffd0a9e947fa5b7367abeb2c10359d0c1 100644 (file)
@@ -8,7 +8,6 @@ package time
 
 import (
        "errors"
-       "io"
        "syscall"
 )
 
@@ -56,9 +55,9 @@ func closefd(fd uintptr) {
 }
 
 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
index 4f41b1a7a3c64dbe156488f4cba0fad5ab45e10c..a4a068f78494c101f455dee014ca3faa2e44fb1b 100644 (file)
@@ -6,7 +6,6 @@ package time
 
 import (
        "errors"
-       "io"
        "syscall"
 )
 
@@ -53,9 +52,9 @@ func closefd(fd uintptr) {
 }
 
 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
index 66777f6d736151a93320013aa6c0685b48653c95..19cd40d847729711297c86468c9f9b73e8fd3864 100644 (file)
@@ -11,6 +11,13 @@ package time
 
 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