diff --git a/go.mod b/go.mod index 8f2f0da..95f89b4 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.5.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 516ff61..2f6e53e 100644 --- a/go.sum +++ b/go.sum @@ -73,6 +73,8 @@ github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2e github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= diff --git a/goextVersion.go b/goextVersion.go index 110dc4e..986a3ff 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.429" +const GoextVersion = "0.0.430" -const GoextVersionTimestamp = "2024-04-08T16:33:44+0200" +const GoextVersionTimestamp = "2024-04-10T15:27:41+0200" diff --git a/langext/json.go b/langext/json.go index 13b0519..9d9d7f4 100644 --- a/langext/json.go +++ b/langext/json.go @@ -63,3 +63,27 @@ func PatchRemJson[JV string | []byte](rawjson JV, key string) (JV, error) { return JV(newjson), nil } + +func MarshalJsonOrPanic(v any) string { + bin, err := json.Marshal(v) + if err != nil { + panic(err) + } + return string(bin) +} + +func MarshalJsonOrDefault(v any, def string) string { + bin, err := json.Marshal(v) + if err != nil { + return def + } + return string(bin) +} + +func MarshalJsonOrNil(v any) *string { + bin, err := json.Marshal(v) + if err != nil { + return nil + } + return Ptr(string(bin)) +}