1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: fix some go line issue in go report card

This commit is contained in:
dudaodong
2022-01-03 14:57:14 +08:00
parent 9266d99249
commit 7a9b0847f9
4 changed files with 12 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ import (
// After creates a function that invokes func once it's called n or more times
func After(n int, fn interface{}) func(args ...interface{}) []reflect.Value {
// Catch programming error while constructing the closure
MustBeFunction(fn)
mustBeFunction(fn)
return func(args ...interface{}) []reflect.Value {
n--
if n < 1 {
@@ -25,7 +25,7 @@ func After(n int, fn interface{}) func(args ...interface{}) []reflect.Value {
// Before creates a function that invokes func once it's called less than n times
func Before(n int, fn interface{}) func(args ...interface{}) []reflect.Value {
// Catch programming error while constructing the closure
MustBeFunction(fn)
mustBeFunction(fn)
var res []reflect.Value
return func(args ...interface{}) []reflect.Value {
if n > 0 {
@@ -73,7 +73,7 @@ func Delay(delay time.Duration, fn interface{}, args ...interface{}) {
// Schedule invoke function every duration time, util close the returned bool chan
func Schedule(d time.Duration, fn interface{}, args ...interface{}) chan bool {
// Catch programming error while constructing the closure
MustBeFunction(fn)
mustBeFunction(fn)
quit := make(chan bool)
go func() {
for {

View File

@@ -31,7 +31,7 @@ func functionValue(function interface{}) reflect.Value {
return v
}
func MustBeFunction(function interface{}) {
func mustBeFunction(function interface{}) {
v := reflect.ValueOf(function)
if v.Kind() != reflect.Func {
panic(fmt.Sprintf("Invalid function type, value of type %T", function))

View File

@@ -25,9 +25,8 @@ func (w *Watcher) Stop() {
func (w *Watcher) GetElapsedTime() time.Duration {
if w.excuting {
return time.Duration(time.Now().UnixNano() - w.startTime)
} else {
return time.Duration(w.stopTime - w.startTime)
}
return time.Duration(w.stopTime - w.startTime)
}
// Reset the watch timer.