Golang template generate array of strings

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Golang template generate array of strings



I want to generate the following



app1 && app2 && app3


app1 && app2 && app3



My template look like following


{{- range ExeApp .}} {{ .Command }} {{- end}}



My code looks like following with command which is array of strings


type App struct {
Data string
Command string
}


func ExeApp(m models) App {

switch m.Type {
case “apps":
return App{
{"# running apps",
string{“app1", “app2", “app3"}},
}




Currently its generated like


[app1 app2 app3]



And I need it like



app1 && app2 && app3 ,


app1 && app2 && app3



I try to play with the template by adding && before the .Command which doesn’t help and in addition I don’t know how to remove the array before and after the apps, any idea what I’m doing wrong here ?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?