fmt.Erroridf

Go 的 fmt 套件的文件描述了格式字串的結構和內容。

erroridf 函式會評估格式字串,然後將結果列印到 ERROR 日誌中並使建構失敗。與 errorf 函式不同,您可以通過將訊息 ID 加入網站設定中的 ignoreLogs 陣列來抑制 erroridf 函式所紀錄的錯誤。

此模板程式碼:

{{ erroridf "error-42" "You should consider fixing this." }}

會產生以下控制台日誌:

ERROR You should consider fixing this.
您可以透過將以下內容加入網站設定來抑制此錯誤:
ignoreLogs = ['error-42']

要抑制這則訊息:

hugo.
     
ignoreLogs:
- error-42
ignoreLogs = ['error-42']
{
   "ignoreLogs": [
      "error-42"
   ]
}