Concatenation of 2 strings in variables #1168
Answered
by
hairyhenderson
github-reader
asked this question in
Q&A
-
Hello I want to do this:
I have googled for a solution. It seems that gomplate cannot concatenate strings. How ca I solve that with gomplate? Hints to go language did not help. They also did not work here? |
Beta Was this translation helpful? Give feedback.
Answered by
hairyhenderson
Jun 1, 2021
Replies: 1 comment
-
Hi @github-reader, I've moved this issue to a discussion instead as this is more of a question than a bug report. There are a number of ways to concatenate strings in the Go templating language that gomplate uses. Usually, what I do is use the $ gomplate -i '{{ $var1 := "val1" }}{{ $var2 := "val2" }}{{ $var3 := print $var1 $var2 }}{{ $var3 }}'
val1val2 You can also use $ gomplate -i '{{ $var1 := "val1" }}{{ $var2 := "val2" }}{{ $var3 := printf "%s%s" $var1 $var2 }}{{ $var3 }}'
val1val2 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hairyhenderson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @github-reader, I've moved this issue to a discussion instead as this is more of a question than a bug report.
There are a number of ways to concatenate strings in the Go templating language that gomplate uses. Usually, what I do is use the
print
keyword:You can also use
printf
if you're familiar with that style of syntax: