diff options
author | Robert Griesemer <gri@golang.org> | 2009-11-09 12:07:39 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-11-09 12:07:39 -0800 |
commit | e940edc7a026293153ba09ece40e8092a2fc2463 (patch) | |
tree | c94a425c84b7a48f91a5d76a222effad70c9a88c /src/pkg/time | |
parent | e067f862f1774ab89a2096a88571a94e3b9cd353 (diff) | |
download | golang-e940edc7a026293153ba09ece40e8092a2fc2463.tar.gz |
remove semis after statements in one-statement statement lists
R=rsc, r
http://go/go-review/1025029
Diffstat (limited to 'src/pkg/time')
-rw-r--r-- | src/pkg/time/tick.go | 10 | ||||
-rw-r--r-- | src/pkg/time/tick_test.go | 6 | ||||
-rw-r--r-- | src/pkg/time/time.go | 26 | ||||
-rw-r--r-- | src/pkg/time/time_test.go | 8 | ||||
-rw-r--r-- | src/pkg/time/zoneinfo.go | 36 |
5 files changed, 43 insertions, 43 deletions
diff --git a/src/pkg/time/tick.go b/src/pkg/time/tick.go index 771fc9f7e..ec526be2a 100644 --- a/src/pkg/time/tick.go +++ b/src/pkg/time/tick.go @@ -40,17 +40,17 @@ func (t *Ticker) ticker(c chan<- int64) { // if c <- now took too long, skip ahead if when < now { // one big step - when += (now-when) / t.ns * t.ns; + when += (now-when) / t.ns * t.ns } for when <= now { // little steps until when > now - when += t.ns; + when += t.ns } Sleep(when-now); now = Nanoseconds(); if t.shutdown { - return; + return } c <- now; } @@ -60,7 +60,7 @@ func (t *Ticker) ticker(c chan<- int64) { // channel only. Useful for clients that have no need to shut down the ticker. func Tick(ns int64) <-chan int64 { if ns <= 0 { - return nil; + return nil } return NewTicker(ns).C; } @@ -70,7 +70,7 @@ func Tick(ns int64) <-chan int64 { // intervals to make up for pauses in delivery of the ticks. func NewTicker(ns int64) *Ticker { if ns <= 0 { - return nil; + return nil } c := make(chan int64); t := &Ticker{c, ns, false}; diff --git a/src/pkg/time/tick_test.go b/src/pkg/time/tick_test.go index 5694a7609..124c13a53 100644 --- a/src/pkg/time/tick_test.go +++ b/src/pkg/time/tick_test.go @@ -17,7 +17,7 @@ func TestTicker(t *testing.T) { ticker := NewTicker(Delta); t0 := Nanoseconds(); for i := 0; i < Count; i++ { - <-ticker.C; + <-ticker.C } ticker.Stop(); t1 := Nanoseconds(); @@ -25,12 +25,12 @@ func TestTicker(t *testing.T) { target := int64(Delta*Count); slop := target*2/10; if ns < target-slop || ns > target+slop { - t.Fatalf("%d ticks of %g ns took %g ns, expected %g", Count, float64(Delta), float64(ns), float64(target)); + t.Fatalf("%d ticks of %g ns took %g ns, expected %g", Count, float64(Delta), float64(ns), float64(target)) } // Now test that the ticker stopped Sleep(2*Delta); _, received := <-ticker.C; if received { - t.Fatalf("Ticker did not shut down"); + t.Fatalf("Ticker did not shut down") } } diff --git a/src/pkg/time/time.go b/src/pkg/time/time.go index 72cd34822..ea1941c13 100644 --- a/src/pkg/time/time.go +++ b/src/pkg/time/time.go @@ -15,7 +15,7 @@ import ( func Seconds() int64 { sec, _, err := os.Time(); if err != nil { - panic("time: os.Time: ", err.String()); + panic("time: os.Time: ", err.String()) } return sec; } @@ -25,7 +25,7 @@ func Seconds() int64 { func Nanoseconds() int64 { sec, nsec, err := os.Time(); if err != nil { - panic("time: os.Time: ", err.String()); + panic("time: os.Time: ", err.String()) } return sec*1e9 + nsec; } @@ -56,7 +56,7 @@ var leapyear = []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} func months(year int64) []int { if year%4 == 0 && (year%100 != 0 || year%400 == 0) { - return leapyear; + return leapyear } return nonleapyear; } @@ -90,7 +90,7 @@ func SecondsToUTC(sec int64) *Time { // Day 0 = January 1, 1970 was a Thursday t.Weekday = int((day+Thursday)%7); if t.Weekday < 0 { - t.Weekday += 7; + t.Weekday += 7 } // Change day from 0 = 1970 to 0 = 2001, @@ -135,7 +135,7 @@ func SecondsToUTC(sec int64) *Time { var m int; yday := int(day); for m = 0; m < 12 && yday >= months[m]; m++ { - yday -= months[m]; + yday -= months[m] } t.Month = m+1; t.Day = yday+1; @@ -199,7 +199,7 @@ func (t *Time) Seconds() int64 { // Add in days this year. months := months(t.Year); for m := 0; m < t.Month - 1; m++ { - day += int64(months[m]); + day += int64(months[m]) } day += int64(t.Day - 1); @@ -257,13 +257,13 @@ var shortMonthNames = []string{ func copy(dst []byte, s string) { for i := 0; i < len(s); i++ { - dst[i] = s[i]; + dst[i] = s[i] } } func decimal(dst []byte, n int) { if n < 0 { - n = 0; + n = 0 } for i := len(dst)-1; i >= 0; i-- { dst[i] = byte(n%10 + '0'); @@ -288,17 +288,17 @@ func format(t *Time, fmt string) string { i++; switch fmt[i] { case 'A': // %A full weekday name - bp = addString(buf, bp, longDayNames[t.Weekday]); + bp = addString(buf, bp, longDayNames[t.Weekday]) case 'a': // %a abbreviated weekday name - bp = addString(buf, bp, shortDayNames[t.Weekday]); + bp = addString(buf, bp, shortDayNames[t.Weekday]) case 'b': // %b abbreviated month name - bp = addString(buf, bp, shortMonthNames[t.Month]); + bp = addString(buf, bp, shortMonthNames[t.Month]) case 'd': // %d day of month (01-31) decimal(buf[bp : bp+2], t.Day); bp += 2; case 'e': // %e day of month ( 1-31) if t.Day >= 10 { - decimal(buf[bp : bp+2], t.Day); + decimal(buf[bp : bp+2], t.Day) } else { buf[bp] = ' '; buf[bp+1] = byte(t.Day + '0'); @@ -320,7 +320,7 @@ func format(t *Time, fmt string) string { decimal(buf[bp : bp+2], int(t.Year % 100)); bp += 2; case 'Z': - bp = addString(buf, bp, t.Zone); + bp = addString(buf, bp, t.Zone) default: buf[bp] = '%'; buf[bp+1] = fmt[i]; diff --git a/src/pkg/time/time_test.go b/src/pkg/time/time_test.go index 5d9d7c27e..93ddcee34 100644 --- a/src/pkg/time/time_test.go +++ b/src/pkg/time/time_test.go @@ -14,7 +14,7 @@ func init() { // Force US Pacific time for daylight-savings // tests below (localtests). Needs to be set // before the first call into the time library. - os.Setenv("TZ", "US/Pacific"); + os.Setenv("TZ", "US/Pacific") } type TimeTest struct { @@ -46,7 +46,7 @@ func same(t, u *Time) bool { t.Second == u.Second && t.Weekday == u.Weekday && t.ZoneOffset == u.ZoneOffset && - t.Zone == u.Zone; + t.Zone == u.Zone } func TestSecondsToUTC(t *testing.T) { @@ -56,7 +56,7 @@ func TestSecondsToUTC(t *testing.T) { tm := SecondsToUTC(sec); newsec := tm.Seconds(); if newsec != sec { - t.Errorf("SecondsToUTC(%d).Seconds() = %d", sec, newsec); + t.Errorf("SecondsToUTC(%d).Seconds() = %d", sec, newsec) } if !same(tm, golden) { t.Errorf("SecondsToUTC(%d):", sec); @@ -73,7 +73,7 @@ func TestSecondsToLocalTime(t *testing.T) { tm := SecondsToLocalTime(sec); newsec := tm.Seconds(); if newsec != sec { - t.Errorf("SecondsToLocalTime(%d).Seconds() = %d", sec, newsec); + t.Errorf("SecondsToLocalTime(%d).Seconds() = %d", sec, newsec) } if !same(tm, golden) { t.Errorf("SecondsToLocalTime(%d):", sec); diff --git a/src/pkg/time/zoneinfo.go b/src/pkg/time/zoneinfo.go index 86f185dad..8e66e0ca6 100644 --- a/src/pkg/time/zoneinfo.go +++ b/src/pkg/time/zoneinfo.go @@ -61,7 +61,7 @@ func (d *data) byte() (n byte, ok bool) { func byteString(p []byte) string { for i := 0; i < len(p); i++ { if p[i] == 0 { - return string(p[0:i]); + return string(p[0:i]) } } return string(p); @@ -85,13 +85,13 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { // 4-byte magic "TZif" if magic := d.read(4); string(magic) != "TZif" { - return nil, false; + return nil, false } // 1-byte version, then 15 bytes of padding var p []byte; if p = d.read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' { - return nil, false; + return nil, false } // six big-endian 32-bit integers: @@ -113,7 +113,7 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { for i := 0; i < 6; i++ { nn, ok := d.big4(); if !ok { - return nil, false; + return nil, false } n[i] = int(nn); } @@ -142,7 +142,7 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { isutc := d.read(n[NUTCLocal]); if d.error { // ran out of data - return nil, false; + return nil, false } // If version == 2, the entire file repeats, this time using @@ -157,16 +157,16 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { var ok bool; var n uint32; if n, ok = zonedata.big4(); !ok { - return nil, false; + return nil, false } z[i].utcoff = int(n); var b byte; if b, ok = zonedata.byte(); !ok { - return nil, false; + return nil, false } z[i].isdst = b != 0; if b, ok = zonedata.byte(); !ok || int(b) >= len(abbrev) { - return nil, false; + return nil, false } z[i].name = byteString(abbrev[b:len(abbrev)]); } @@ -177,18 +177,18 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { var ok bool; var n uint32; if n, ok = txtimes.big4(); !ok { - return nil, false; + return nil, false } zt[i].time = int32(n); if int(txzones[i]) >= len(z) { - return nil, false; + return nil, false } zt[i].zone = &z[txzones[i]]; if i < len(isstd) { - zt[i].isstd = isstd[i] != 0; + zt[i].isstd = isstd[i] != 0 } if i < len(isutc) { - zt[i].isutc = isutc[i] != 0; + zt[i].isutc = isutc[i] != 0 } } return zt, true; @@ -197,7 +197,7 @@ func parseinfo(bytes []byte) (zt []zonetime, ok bool) { func readinfofile(name string) ([]zonetime, bool) { buf, err := io.ReadFile(name); if err != nil { - return nil, false; + return nil, false } return parseinfo(buf); } @@ -213,9 +213,9 @@ func setupZone() { tz, err := os.Getenverror("TZ"); switch { case err == os.ENOENV: - zones, _ = readinfofile("/etc/localtime"); + zones, _ = readinfofile("/etc/localtime") case len(tz) > 0: - zones, _ = readinfofile(zoneDir+tz); + zones, _ = readinfofile(zoneDir+tz) case len(tz) == 0: // do nothing: use UTC } @@ -224,7 +224,7 @@ func setupZone() { func lookupTimezone(sec int64) (zone string, offset int) { once.Do(setupZone); if len(zones) == 0 { - return "UTC", 0; + return "UTC", 0 } // Binary search for entry with largest time <= sec @@ -232,9 +232,9 @@ func lookupTimezone(sec int64) (zone string, offset int) { for len(tz) > 1 { m := len(tz)/2; if sec < int64(tz[m].time) { - tz = tz[0:m]; + tz = tz[0:m] } else { - tz = tz[m:len(tz)]; + tz = tz[m:len(tz)] } } z := tz[0].zone; |