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

Change return types of "split" and "splitn" to map[string]interface{} (instead of map[string]string) #397

Open
rpasche opened this issue Apr 30, 2024 · 0 comments

Comments

@rpasche
Copy link

rpasche commented Apr 30, 2024

Hi,

I just noticed, that I cannot use hasKey function on a dict created by the split or splitn functions, as they both return dicts of type map[string]string whereas most of the functions in dict.go expect a dict of type map[string]interface{}

{{- $mysplit := splitn "$" 2 "foo" }}
{{- if hasKey $mysplit "_1" }}
  2nd_part: {{ $mysplit._1 }}
{{- end }}

The error I get is

Error: template: .... at <$mysplit>: wrong type for value; expected map[string]interface {}; got map[string]string

Basically, the same error when trying to use get function

{{- $mysplit := splitn "$" 2 "foo" }}
1st_part: {{ get $mysplit. "_0" }}

The error I get is

Error: template: .... at <$mysplit>: wrong type for value; expected map[string]interface {}; got map[string]string
@rpasche rpasche changed the title Change return types of "split" and "splitn" to map[string]interface{} (instead of map[string]string Change return types of "split" and "splitn" to map[string]interface{} (instead of map[string]string) Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant