I had to replace the single use of io/ioutil
in the time package with a bytes.Buffer since
there would've been a dependency cycle.
There are no other uses of os.Time.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/
5372054
"os"
"path/filepath"
"strconv"
+ "time"
)
// Random number state, accessed without lock; racy but harmless.
var rand uint32
func reseed() uint32 {
- sec, nsec, _ := os.Time()
- return uint32(sec*1e9 + nsec + int64(os.Getpid()))
+ return uint32(time.Nanoseconds() + int64(os.Getpid()))
}
func nextSuffix() string {
package net
import (
- "os"
"sync"
+ "time"
)
const cacheMaxAge = int64(300) // 5 minutes.
}
func readHosts() {
- now, _, _ := os.Time()
+ now := time.Seconds()
hp := hostsPath
if len(hosts.byName) == 0 || hosts.time+cacheMaxAge <= now || hosts.path != hp {
hs := make(map[string][]string)
}
}
// Update the data cache.
- hosts.time, _, _ = os.Time()
+ hosts.time = time.Seconds()
hosts.path = hp
hosts.byName = hs
hosts.byAddr = is
package time
import (
- "io/ioutil"
+ "bytes"
"os"
)
}
func readinfofile(name string) ([]zonetime, bool) {
- buf, err := ioutil.ReadFile(name)
+ var b bytes.Buffer
+
+ f, err := os.Open(name)
if err != nil {
return nil, false
}
- return parseinfo(buf)
+ defer f.Close()
+ if _, err := b.ReadFrom(f); err != nil {
+ return nil, false
+ }
+ return parseinfo(b.Bytes())
}
func setupTestingZone() {