func main() { stock.Get() ShowAll(stock) fmt.Println("-----------------------------") stock.PlusData() ShowAll(stock) fmt.Println("-----------------------------") fmt.Println(tradingdays.IsOpen(2015, 5, 1)) }
// TradeOpen is "./open" page. func TradeOpen(w http.ResponseWriter, req *http.Request) { var jsonStr []byte if data, err := strconv.ParseInt(req.FormValue("q"), 10, 64); err != nil { jsonStr, _ = json.Marshal(&errorJSON{Error: "Wrong date format"}) } else { if csvcachetime.InCache(defaultcachetime) != true { tradingdays.DownloadCSV(true) csvcachetime.Set() log.Println("DownloadCSV.") } date := time.Unix(data, 0) jsonStr, _ = json.Marshal(&tradeJSON{ Date: date.UTC(), Open: tradingdays.IsOpen(date.Year(), date.Month(), date.Day())}) } w.Header().Set("Content-Type", "application/json") w.Write(jsonStr) Log(req) }