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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

panic: open template/layout-main-page.html:

panic: open template/layout-main-page.html:

Go
德瑪西亞99 2023-02-21 19:12:07
我是 Golang 的新手,我試圖在我的應(yīng)用程序中運(yùn)行一個(gè)簡(jiǎn)單的測(cè)試,但每次都會(huì)發(fā)生恐慌。我找不到問(wèn)題所在。我看過(guò)幾個(gè)地方,但找不到解決方案。隨時(shí)問(wèn)我關(guān)于代碼的任何問(wèn)題,如果你有任何問(wèn)題,盡管問(wèn)。錯(cuò)誤信息:PS D:\projetos go\api-ranking-crypto> go test ./test/panic: open template/layout-main-page.html: The system cannot find the path specified.goroutine 1 [running]:html/template.Must(...)        D:/Go/src/html/template/template.go:374github.com/maickmachado/upvote-api/controllers.init()        D:/projetos go/api-ranking-crypto/controllers/controllers.go:15 +0x1d8FAIL    github.com/maickmachado/upvote-api/test 0.209sFAIL我的測(cè)試代碼:    func TestHealthCheck(t *testing.T) {    tt := []struct {        name   string        method string        statusCode int    }{        {            name:   "status ok",            method: http.MethodGet,            statusCode: http.StatusOK,        },    }    for _, tc := range tt {        t.Run(tc.name, func(t *testing.T) {            request := httptest.NewRequest(tc.method, "/healthcheck", nil)            responseRecorder := httptest.NewRecorder()            controllers.HealthCheck(responseRecorder, request)            if responseRecorder.Code != tc.statusCode {                t.Errorf("Want status '%d', got '%d'", tc.statusCode, responseRecorder.Code)            }        })    }}
查看完整描述

1 回答

?
開(kāi)心每一天1111

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個(gè)贊

我改變了一些東西。


將模板放入Handle函數(shù)中,從中取出模板。必須:


func ErrorHandler404(w http.ResponseWriter, r *http.Request) {


    TmplError, _ := template.ParseFiles("./template/layout-erro.html")


    w.WriteHeader(http.StatusNotFound)

    data := models.DetailPageData{

        PageTitle: "Erro 404 - Not Found",

    }

    err := TmplError.Execute(w, data)

    if err != nil {

        log.Println(err)

    }

}


查看完整回答
反對(duì) 回復(fù) 2023-02-21
  • 1 回答
  • 0 關(guān)注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

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