From 4a254746de7246ddf8ac131f734f224d49e927b7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 2 Jun 2024 01:17:36 +0200 Subject: chore(gonf): removed opinionated static checkers --- pkg/values.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'pkg/values.go') diff --git a/pkg/values.go b/pkg/values.go index 70fc9fe..c85de01 100644 --- a/pkg/values.go +++ b/pkg/values.go @@ -14,20 +14,19 @@ type Value interface { } func interfaceToValue(v any) Value { - if vv, ok := v.([]byte); ok { + switch vv := v.(type) { + case []byte: return &BytesValue{vv} - } - if vv, ok := v.(int); ok { + case int: return &IntValue{vv} - } - if vv, ok := v.(string); ok { + case string: return &StringValue{vv} - } - if vv, ok := v.(*VariablePromise); ok { + case *VariablePromise: return vv + default: + slog.Error("interfaceToValue", "value", v, "error", "Not Implemented") + panic(fmt.Sprintf("interfaceToValue cannot take type %T as argument. Value was %#v.", v, v)) } - slog.Error("interfaceToValue", "value", v, "error", "Not Implemented") - panic(fmt.Sprintf("interfaceToValue cannot take type %T as argument. Value was %#v.", v, v)) } func interfaceToTemplateValue(v any) Value { -- cgit v1.2.3