fuwencai 2 月之前
父節點
當前提交
9c247af470
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      rpc/knowledge/util/hanlp.go

+ 6 - 1
rpc/knowledge/util/hanlp.go

@@ -5,6 +5,7 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"errors"
+	"github.com/zeromicro/go-zero/core/logx"
 	"io/ioutil"
 	"log"
 	"net/http"
@@ -34,7 +35,11 @@ func getResult(str, url string) []map[string]interface{} {
 		resMap []map[string]interface{}
 	)
 	str = hanlpRegTail.ReplaceAllString(str, "")
-	resp, _ := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader("content="+str))
+	resp, err := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader("content="+str))
+	logx.Error("分词", url, err)
+	if err != nil {
+		return resMap
+	}
 	bs, err = ioutil.ReadAll(resp.Body)
 	if err != nil {
 		log.Printf("获取hanlp分词结果出错:[%v]", err)