This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package CommonUtil
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
)
var swaggerFile = "docs/swagger.json"
/**
功能:读取swagger的生成json
作者:黄海
时间:2020-03-16
*/
func ReadSwaggerJson() interface{} {
//读取doc目录下的swagger.json
f, err := os.Open(swaggerFile)
if err != nil {
log.Fatal("读取swagger.json失败!")
return nil
}
content, _ := ioutil.ReadAll(f)
var jsonBody interface{}
err = json.Unmarshal(content, &jsonBody)
fmt.Println("ERROR: ", err.Error())
return jsonBody