diff --git a/README.md b/README.md index 15b97a9..8664c3b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Not supported (yet?): - structs in anonymous types - structs in function input or output - structs in generic type +- `any("foobar")` reported as `string` instead of `any` (see #2) ## Examples @@ -104,7 +105,7 @@ func main() { ## 🤝 Contributing -- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :)) +- Ping me on Twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :)) - Fork the [project](https://github.com/samber/go-type-to-string) - Fix [open issues](https://github.com/samber/go-type-to-string/issues) or request new features diff --git a/converter_test.go b/converter_test.go index 68c982c..a852762 100644 --- a/converter_test.go +++ b/converter_test.go @@ -148,6 +148,8 @@ func TestGetType(t *testing.T) { is.Equal("interface {}", name) name = GetType[*any]() is.Equal("*interface {}", name) + name = GetType[**any]() + is.Equal("**interface {}", name) // all mixed name = GetType[[]chan *[]*map[*testStruct][]map[chan int]*map[testInterface]func(int, string) bool]() @@ -163,11 +165,18 @@ func TestGetValueType(t *testing.T) { a = "" name = GetValueType(a) - is.Equal("interface {}", name) // not string + is.Equal("interface {}", name) // not string ? a = "" name = GetValueType(&a) is.Equal("*interface {}", name) + + a = 42 + name = GetValueType(a) + is.Equal("interface {}", name) // not int ? + + name = GetValueType(any("42")) + is.Equal("interface {}", name) // not string ? } func TestGetReflectValueType(t *testing.T) {