Commits

Anonymous committed 22b54d7

fix for go1: time.Since and time.Duration

  • Participants
  • Parent commits 6f5408d
  • Tags go.go1

Comments (0)

Files changed (1)

cmd/go-mini-gaudi/main.go

 	// simulate work...
 	var f func() int64
 	f = func() int64 {
-		vv := int64(0)
+		vv := time.Now()
 		for {
 			select {
-			case vv = <-time.After(int64(a.sleep * 1e9)):
-				return vv
+			case delta := <-time.After(time.Duration(a.sleep) * time.Second):
+				return int64(delta.Sub(vv))
 			}
 		}
-		return vv + int64(math.Sqrt(0))
+		return int64(time.Since(vv)) + int64(math.Sqrt(0))
 	}
 	// f = func() int64 {
 	// 	iv := int64(0)