Skip to content
This repository was archived by the owner on Mar 8, 2026. It is now read-only.

Commit 2f9a604

Browse files
committed
GetFloat32WithDefault
1 parent 7272d0e commit 2f9a604

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
lint:
22
golangci-lint run
33

4-
test:
5-
go test -count=1 ./...
4+
# -cover coverage.
5+
# -shuffle=on runs the tests in a random order.
6+
# -race activates the data race detector.
7+
# -vet=all runs go vet to identify significant problems. If go vet finds any problems, go test reports those and does not run the test binary.
8+
# -failfast stops test execution when a given unit test fails. It allows tests executed in parallel to finish.
9+
.PHONY: test
10+
test: ## Go recompile and test with coverage
11+
go test ./... -cover -shuffle=on -race -vet=all -failfast

env/env.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ func GetIntWithDefault(key string, defaultValue int) int {
4444
return res
4545
}
4646

47-
func GetFloat64WithDefault(key string, defaultValue float64) float64 {
47+
func GetFloat32WithDefault(key string, defaultValue float64) float64 {
4848

4949
value, exists := os.LookupEnv(key)
5050
if !exists {
5151
return defaultValue
5252
}
5353

54-
res, err := strconv.ParseFloat(value, 64)
54+
res, err := strconv.ParseFloat(value, 32)
5555
if err != nil {
56-
slog.Warn("failed to parse environment variable that should be float64. using default",
56+
slog.Warn("failed to parse environment variable that should be float32. using default",
5757
"error", err, "env key", key, "value", value, "default", defaultValue)
5858
return defaultValue
5959
}

0 commit comments

Comments
 (0)