具有动态格式字符串且没有其他参数的 printf 样式函数应使用打印样式函数
我的 VScode 不断fmt.Fprintf(w, prettyJSON.String())用上述警告突出显示我的陈述。不知道这意味着什么,或者如何解决。这是我如何使用的示例Fprintf():
func (s *Server) getWorkSpaces(w http.ResponseWriter, r *http.Request) {
client := &http.Client{}
var prettyJSON bytes.Buffer
req, err := http.NewRequest("GET", "url.com", nil)
if err != nil {
// if there was an error parsing the request, return an error to user and quit function
responses.ERROR(w, http.StatusBadRequest, fmt.Errorf("unable to read request body: %v", err))
return
}
resp, err := client.Do(req)
if err != nil {
// if there was an error parsing the request, return an error to user and quit function
responses.ERROR(w, http.StatusBadRequest, fmt.Errorf("unable to read request body: %v", err))
return
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
error := json.Indent(&prettyJSON, body, "", "\t")
if error != nil {
log.Println("JSON parse error: ", error)
return
}
fmt.Fprintf(w, prettyJSON.String())
}
我怎样才能停止这个错误?有人可以向我解释为什么我的 VScode 会在屏幕上显示它吗?请注意,我的代码运行良好。
千万里不及你
相关分类