mirror of
https://github.com/golang/go
synced 2024-11-23 07:00:05 -07:00
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>
This commit is contained in:
parent
561c948844
commit
d88261fb65
@ -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"},
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user