summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-09-25 22:50:42 -0300
committerEuAndreh <eu@euandre.org>2024-09-25 22:50:42 -0300
commit849904e13e6bf2a2607ec290950a8ad165fcb2de (patch)
tree07690721cc1ed5e7007df8d114c5d1a51ac687ca
parentsrc/gobang.go: Support static and dynamic args in MaeCounter() (diff)
downloadgobang-849904e13e6bf2a2607ec290950a8ad165fcb2de.tar.gz
gobang-849904e13e6bf2a2607ec290950a8ad165fcb2de.tar.xz
src/gobang.go: Remove return value from Timed() thunk
-rw-r--r--src/gobang.go7
-rw-r--r--tests/gobang.go17
2 files changed, 3 insertions, 21 deletions
diff --git a/src/gobang.go b/src/gobang.go
index bef87aa..9d544c9 100644
--- a/src/gobang.go
+++ b/src/gobang.go
@@ -202,17 +202,16 @@ func metric(type_ string, label string, args ...any) {
)
}
-func Timed(label string, thunk func() any, args ...any) any {
+func Timed(label string, thunk func(), args ...any) {
var (
start time.Time
end time.Time
- ret any
)
{
start = time.Now()
- ret = thunk()
+ thunk()
end = time.Now()
}
@@ -228,8 +227,6 @@ func Timed(label string, thunk func() any, args ...any) any {
args,
)...,
)
-
- return ret
}
func MakeCounter(label string, staticArgs ...any) func(...any) {
diff --git a/tests/gobang.go b/tests/gobang.go
index 6813249..954f588 100644
--- a/tests/gobang.go
+++ b/tests/gobang.go
@@ -394,7 +394,7 @@ func test_Timed() {
SetLoggerOutput(s)
emitMetric = true
- Timed("timer-label", func() any { return nil }, "key-1", "value-1")
+ Timed("timer-label", func() {}, "key-1", "value-1")
var data map[string]interface{}
err := json.Unmarshal([]byte(s.String()), &data)
@@ -415,21 +415,6 @@ func test_Timed() {
slog.SetDefault(savedLogger)
emitMetric = savedFlag
})
-
- Testing("it propagates the return value", func() {
- savedLogger := slog.Default()
- savedFlag := emitMetric
-
- s := new(strings.Builder)
- SetLoggerOutput(s)
- emitMetric = true
-
- val := Timed("timer-label", func() any { return 123 }, "key-1", "value-1")
- AssertEqual(val, 123)
-
- slog.SetDefault(savedLogger)
- emitMetric = savedFlag
- })
}
func test_MakeCounter() {