From 94d2c9e2419713323f1d2178d66fa2aa82ed21a1 Mon Sep 17 00:00:00 2001 From: Robert Lillack Date: Fri, 29 Apr 2022 17:58:12 +0200 Subject: [PATCH] mars-gen: Add support for route generation when any params are used. --- cmd/mars-gen/main_test.go | 28 ++++++++++++++++------------ cmd/mars-gen/reflect.go | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cmd/mars-gen/main_test.go b/cmd/mars-gen/main_test.go index cc0dfaf..3d67b57 100644 --- a/cmd/mars-gen/main_test.go +++ b/cmd/mars-gen/main_test.go @@ -10,18 +10,22 @@ import ( ) var TypeExprs = map[string]TypeExpr{ - "int": {"int", "", 0, true}, - "*int": {"*int", "", 1, true}, - "[]int": {"[]int", "", 2, true}, - "...int": {"[]int", "", 2, true}, - "[]*int": {"[]*int", "", 3, true}, - "...*int": {"[]*int", "", 3, true}, - "MyType": {"MyType", "pkg", 0, true}, - "*MyType": {"*MyType", "pkg", 1, true}, - "[]MyType": {"[]MyType", "pkg", 2, true}, - "...MyType": {"[]MyType", "pkg", 2, true}, - "[]*MyType": {"[]*MyType", "pkg", 3, true}, - "...*MyType": {"[]*MyType", "pkg", 3, true}, + "int": {"int", "", 0, true}, + "*int": {"*int", "", 1, true}, + "[]int": {"[]int", "", 2, true}, + "...int": {"[]int", "", 2, true}, + "[]*int": {"[]*int", "", 3, true}, + "...*int": {"[]*int", "", 3, true}, + "MyType": {"MyType", "pkg", 0, true}, + "*MyType": {"*MyType", "pkg", 1, true}, + "[]MyType": {"[]MyType", "pkg", 2, true}, + "...MyType": {"[]MyType", "pkg", 2, true}, + "[]*MyType": {"[]*MyType", "pkg", 3, true}, + "...*MyType": {"[]*MyType", "pkg", 3, true}, + "interface{}": {"interface{}", "", 0, true}, + "...interface{}": {"[]interface{}", "", 2, true}, + "any": {"any", "", 0, true}, + "...any": {"[]any", "", 2, true}, } func TestTypeExpr(t *testing.T) { diff --git a/cmd/mars-gen/reflect.go b/cmd/mars-gen/reflect.go index c0ceee2..d3170d8 100644 --- a/cmd/mars-gen/reflect.go +++ b/cmd/mars-gen/reflect.go @@ -631,4 +631,5 @@ var builtinTypes = map[string]struct{}{ "uint64": {}, "uint8": {}, "uintptr": {}, + "any": {}, }