Golang 服务监听保存文件


package main

import (
 "github.com/magiconair/properties"
 "github.com/CrowdSurge/banner"
 "net/http"
 "encoding/json"
 "fmt"
 "path/filepath"
 "log"
 "os"
 "math/rand"
 "time"
)

const (
 PARAMETER_NOT_EMPTY = "必要参数不能为空!"
 ERROR_DATE_FORMAT = "错误的日期格式!"
 UPLOAD_SUCCESS = "上传成功!"
 SERVICE_START_SUCCESS = "服务启动成功!"
)

type StatusMessage struct {
 Name   string
 Code    string
 Desc string
}

var savePath string

func RandInt64(min, max int64) int64 {
 rand.Seed(time.Now().UnixNano())
 return min + rand.Int63n(max-min)
}

func showTip()  {
 b := [6] string {"test", "who am i", "great programming", "not bug", "not smoking"}

 banner.Print(b[RandInt64(0,int64(len(b)))])

 for i:=0;i<5 1="" :="json.Marshal(StatusMessage{UPLOAD_SUCCESS," _="" api="" b="" closeerr="" config.properties="" createerr="" data:="" data="=" err="" file="" fmt.println="" fullpath="" func="" http.handlefunc="" http.request="" http.responsewriter="" i="" if="" key:="" key="" listen="" log.fatal="" log.println="" main="" nil="" p="" pre="" properties.utf8="" r.parseform="" r="" receive="" resp.write="" resp="" return="" save="" savepath="" sender:="" sender="" showtip="" status="" sundun-00="" sundun-01="" sundun-02="" time.second="" time.sleep="" timestamp:="" timestamp="" writeerr="" xml="">

评论