“12306”的架构到底有多牛逼?( 二 )

】packagemain
import(
"net/http"
"os"
"strings"
)
funcmain{
http.HandleFunc("/buy/ticket",handleReq)
http.ListenAndServe(":3001",nil)
}
//处理请求函数,根据请求将响应结果信息写入日志
funchandleReq(whttp.ResponseWriter,r*http.Request){
failedMsg:="handleinport:"
writeLog(failedMsg,"./stat.log")
}
//写入日志
funcwriteLog(msgstring,logPathstring){
fd,_:=os.OpenFile(logPath,os.O_RDWR|os.O_CREATE|os.O_APPEND,0644)
deferfd.Close
content:=strings.Join([]string{msg,"rn