package cfg import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "encoding/json" "os" "strings" "time" ) func InitMq() { data, _ := json.Marshal(MQ) filePutContents("init_rabbit_mq", string(data)) err := rabbit.Init(MQ.Host, MQ.Port, MQ.User, MQ.Pwd) if err != nil { filePutContents("init_rabbit_mq", err.Error()) return } } func filePutContents(fileName string, content string) { fd, _ := os.OpenFile("./tmp/"+fileName+".log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) fd_time := time.Now().Format("2006-01-02 15:04:05") fd_content := strings.Join([]string{"[", fd_time, "] ", content, "\n"}, "") buf := []byte(fd_content) fd.Write(buf) fd.Close() }