Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a map[string]interface{} to be provided as the params also #32

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Template.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ func (t *Template) fileToXMLStruct(fname string) *xmlNode {
func (t *Template) Params(v interface{}) {
// t.params = collectParams("", v)
switch val := v.(type) {
case map[string]interface{}:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did merged PR, but there was no issue (just no good comments).
There are some basic types, but complex types (like map) is sent through StructParams. Which now is confusing because there is similar func StructToParams.
StructParams will become AnyToParams to avoid confusion

	default:
		if reflect.ValueOf(v).Kind() == reflect.Struct {
			t.params = StructToParams(val)
		} else {
			// any other type try to convert
			t.params = AnyToParams(val)
		}
	}
	```

It will be changed in next release. See: `t.params_test.go`

t.params = mapToParams(val)
case string:
t.params = JSONToParams([]byte(val))
case []byte:
Expand Down
Loading