第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang模板從字符串數(shù)組生成值錯誤

Golang模板從字符串數(shù)組生成值錯誤

Go
四季花海 2021-04-08 22:18:08
我正在使用Golang項目,需要生成以下內(nèi)容app1 && app2 && app3我的模板如下所示{{- range ExeApp .}} {{ .Command }} {{- end}}我的代碼看起來像是帶有字符串數(shù)組的命令type App struct {   Data    string   Command []string}//This is the functionfunc ExeApp(m models) []App {   switch m.Type {   case “apps":      return []App{         {"# running apps",            []string{“app1", “app2", “app3"}},      }…目前其生成像[app1 app2 app3]我需要它app1 && app2 && app3 ,我嘗試通過在.Command之前添加&&來處理模板,這無濟于事,此外,我不知道如何在應用程序前后刪除數(shù)組[],知道我在這里做錯了什么嗎?我已經(jīng)嘗試過以下{{- range .ExeApp}} {{range .Command }} && {{.}} {{end}} {{- end}}但是現(xiàn)在我正在轉(zhuǎn)儲并出現(xiàn)錯誤: unexpected EOF或未定義函數(shù)“ Command”在運行模板時生成的代碼是:funcMap := template.FuncMap{    "ExeApp": ExeApp,}t, err := template.New("file.txt").Funcs(funcMap).ParseFiles(container)如果我使用第一個結(jié)構(gòu)(沒有字符串數(shù)組的相同結(jié)構(gòu),當然也要修改對象的代碼),那么一切都會按預期進行也嘗試這個 {{-range .ExeApp}} {{range .Command}} {{.}} {{end}} {{end}}現(xiàn)在我收到錯誤executing "file.txt" at <.ExeApp>: can't evaluate field ExeApp in type *models為什么 :(
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 494 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號