fmt.Warnidf

New in v0.123.0

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

warnidf 函式評估格式字串,然後將結果輸出至警告日誌。與 warnf 函式不同,您可以通過將訊息 ID 添加到網站配置中的 ignoreLogs 陣列中來抑制由 warnidf 函式紀錄的警告。

以下模板程式碼:

{{ warnidf "warning-42" "You should consider fixing this." }}

會產生以下的控制台日誌:

WARN You should consider fixing this.
You can suppress this warning by adding the following to your site configuration:
ignoreLogs = ['warning-42']

若要抑制此訊息,請將以下內容新增到您的網站配置:

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