当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.Fatalln函数代码示例

本文整理汇总了Golang中Logger.Fatalln函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalln函数的具体用法?Golang Fatalln怎么用?Golang Fatalln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Fatalln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: InterfaceToFloat64

func InterfaceToFloat64(iv interface{}) (retV float64) {
	//logger.Debugf("iv=%v\n", iv)

	switch ivTo := iv.(type) {
	case float64:
		//	logger.Traceln(ivTo, "is float64")
		retV = ivTo
	case string:
		//	logger.Traceln(ivTo, "is string")
		{
			var err error
			retV, err = strconv.ParseFloat(ivTo, 64)
			if err != nil {
				logger.Fatalln("convert failed, crash!")
				return 0
			}
		}
	default:
		logger.Fatalln(ivTo)
		logger.Fatalln("don't know the type, crash!")
		return 0
	}

	return retV
}
开发者ID:9cat,项目名称:btcrobot,代码行数:25,代码来源:utils.go

示例2: parse_buy_sell

func parse_buy_sell(sells_buys []interface{}, sells_buys_data *[10]SellBuy) bool {
	for k, v := range sells_buys {
		switch vt := v.(type) {
		case map[string]interface{}:
			logger.Debugln(k, " is a map:")
			logger.Debugf("sells/buys[%d]\n", k)

			for ik, iv := range vt {
				switch ik {
				case "price":
					sells_buys_data[k].Price = util.InterfaceToFloat64(iv)
				case "level":
					sells_buys_data[k].Level = util.InterfaceToFloat64(iv)
				case "amount":
					sells_buys_data[k].Amount = util.InterfaceToFloat64(iv)
				}
			}
		default:
			logger.Errorln(k, v)
			logger.Fatalln("don't know the type, crash!")
			return false
		}
	}

	return true
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:26,代码来源:orderbook.go

示例3: parse_trade

func parse_trade(trades []interface{}, trades_data *[60]Trade) bool {
	for k, v := range trades {
		switch vt := v.(type) {
		case map[string]interface{}:
			logger.Debugln(k, " is a map:")
			logger.Debugf("trades[%d]\n", k)

			for ik, iv := range vt {
				switch ik {
				case "time":
					trades_data[k].Time = iv.(string)
				case "price":
					trades_data[k].Price = util.InterfaceToFloat64(iv)
				case "amount":
					trades_data[k].Amount = util.InterfaceToFloat64(iv)
				case "type":
					trades_data[k].Type = iv.(string)
				}
			}
		default:
			logger.Errorln(k, v)
			logger.Fatalln("don't know the type, crash!")
			return false
		}
	}
	return true
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:27,代码来源:orderbook.go

示例4: check_json_result

func (w *OkcoinTrade) check_json_result(body string) (errorMsg ErrorMsg, ret bool) {
	if strings.Contains(body, "result") != true {
		ret = false
		return
	}

	doc := json.NewDecoder(strings.NewReader(body))

	if err := doc.Decode(&errorMsg); err == io.EOF {
		logger.Traceln(err)
	} else if err != nil {
		logger.Fatal(err)
		logger.Fatalln(body)
	}

	if errorMsg.Result != true {
		logger.Errorln(errorMsg)
		SetLastError(errorMsg.ErrorCode)
		ret = false
		return
	}

	ret = true
	return
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:25,代码来源:tradeapi.go

示例5: parse_trade

func parse_trade(trades []interface{}, trades_data *[15]Trade) {
	for k, v := range trades {
		switch vt := v.(type) {
		case map[string]interface{}:
			logger.Traceln(k, " is a map:")
			logger.Tracef("trades[%d]\n", k)

			for ik, iv := range vt {
				switch ik {
				case "time":
					trades_data[k].time = iv.(string)
				case "price":
					trades_data[k].price = InterfaceToFloat64(iv)
				case "amount":
					trades_data[k].amount = InterfaceToFloat64(iv)
				case "type":
					trades_data[k].type_ = iv.(string)
				}
			}
		default:
			logger.Errorln(k, v)
			logger.Fatalln("don't know the type, crash!")
		}
	}
}
开发者ID:kuainiao,项目名称:btcrobot,代码行数:25,代码来源:huobidetail.go

示例6: parse_topsell

func parse_topsell(topsells map[string]interface{}, topsells_data *[5]Top_buy_sell) {
	index := 4
	for k, v := range topsells {
		switch vt := v.(type) {
		case map[string]interface{}:
			logger.Traceln(k, " is a map:")
			logger.Tracef("topsells[%s]\n", k)

			for ik, iv := range vt {
				logger.Traceln(ik, iv)
				switch ik {
				case "price":
					topsells_data[index].Price = InterfaceToFloat64(iv)
				case "amount":
					topsells_data[index].amount = InterfaceToFloat64(iv)
				case "level":
					topsells_data[index].level = InterfaceToFloat64(iv)
				case "accu":
					topsells_data[index].accu = InterfaceToFloat64(iv)
				}
			}

			index--

		default:
			logger.Errorln(k, v)
			logger.Fatalln("don't know the type, crash!")
		}
	}
}
开发者ID:kuainiao,项目名称:btcrobot,代码行数:30,代码来源:huobidetail.go

示例7: parse_topsell

// just fuck the huobi old shit bug
func parse_topsell(topsells map[string]interface{}, topsells_data *[5]Top_buy_sell) bool {
	index := 4
	for k, v := range topsells {
		switch vt := v.(type) {
		case map[string]interface{}:
			logger.Debugln(k, " is a map:")
			logger.Debugf("topsells[%s]\n", k)

			for ik, iv := range vt {
				logger.Debugln(ik, iv)
				switch ik {
				case "price":
					topsells_data[index].Price = util.InterfaceToFloat64(iv)
				case "amount":
					topsells_data[index].Amount = util.InterfaceToFloat64(iv)
				case "level":
					topsells_data[index].Level = util.InterfaceToFloat64(iv)
				case "accu":
					topsells_data[index].Accu = util.InterfaceToFloat64(iv)
				}
			}

			index--

		default:
			logger.Errorln(k, v)
			logger.Fatalln("don't know the type, crash!")
			return false
		}
	}
	return true
}
开发者ID:cnspot,项目名称:btcrobot,代码行数:33,代码来源:orderbook.go

示例8: stringt2float64

func stringt2float64(in string) float64 {
	out, err := strconv.ParseFloat(in, 64)
	if err != nil {
		logger.Fatalln("don't know the type, crash!")
		logger.Traceln("config item amount is not number, get from buy price")
	}

	return out
}
开发者ID:jackyxie,项目名称:btcrobot,代码行数:9,代码来源:utils.go

示例9: tradeAPI

func tradeAPI() (tradeAPI TradeAPI) {
	if Option["tradecenter"] == "huobi" {
		tradeAPI = huobi.NewHuobi()
	} else if Option["tradecenter"] == "okcoin" {
		tradeAPI = okcoin.NewOkcoin()
	} else {
		logger.Fatalln("Please config the tradecenter firstly...")

	}
	return
}
开发者ID:jmliu88,项目名称:btcrobot,代码行数:11,代码来源:monitor.go

示例10: marketAPI

func marketAPI() (marketAPI MarketAPI) {
	if Option["datacenter"] == "huobi" {
		marketAPI = huobi.NewHuobi()
	} else if Option["datacenter"] == "okcoin" {
		marketAPI = okcoin.NewOkcoin()
	} else {
		logger.Fatalln("Please config the datacenter firstly...")

	}
	return
}
开发者ID:jmliu88,项目名称:btcrobot,代码行数:11,代码来源:monitor.go

示例11: RobotWorker

func RobotWorker() {
	fmt.Println("env", Config["env"])
	if Config["env"] == "dev" {
		fmt.Println("test working...")
		var tradeAPI common.TradeAPI
		tradeAPI = huobi.NewHuobi()
		tradeAPI.Get_account_info()
		symbol := "btc_cny"
		tradeAPI.GetOrderBook(symbol)

		//testHuobiAPI()
		//testOkcoinLTCAPI()
		return
	}

	ticker := time.NewTicker(2 * time.Second) //2s
	defer ticker.Stop()

	var tradeAPI common.TradeAPI
	tradeAPI = huobi.NewHuobi()
	tradeAPI.Get_account_info()

	tradeAPI = okcoin.NewOkcoin()
	tradeAPI.Get_account_info()

	if Option["tradecenter"] == "huobi" {
		tradeAPI = huobi.NewHuobi()
	} else if Option["tradecenter"] == "okcoin" {
		tradeAPI = okcoin.NewOkcoin()
	} else {
		logger.Fatalln("Please config the tradecenter firstly...")
		return
	}
	peroid, _ := strconv.Atoi(Option["tick_interval"])
	totalHour, _ := strconv.ParseInt(Option["totalHour"], 0, 64)
	if totalHour < 1 {
		totalHour = 1
	}

	fmt.Println("robot working...")

	go func() {
		for _ = range ticker.C {
			tradeAPI.AnalyzeKLine(peroid)
		}
	}()

	logger.Infof("程序将持续运行%d小时后停止", time.Duration(totalHour))

	time.Sleep(time.Duration(totalHour) * time.Hour)

	logger.Infof("程序到达设定时长%d小时,停止运行。", time.Duration(totalHour))
}
开发者ID:kewinwang,项目名称:btcrobot,代码行数:53,代码来源:entry.go

示例12: parseMinuteCSV

func parseMinuteCSV(filename string) (MinuteRecords []MinuteRecord) {

	// convert to standard csv file
	data2csv(filename, 3)

	file, err := os.Open(filename + ".csv")
	if err != nil {
		fmt.Println("ParseMinuteCSV Error:", err)
		return
	}
	defer file.Close()
	reader := csv.NewReader(file)
	/*
		record, err := reader.ReadAll()
		fmt.Println(record)
		return
	*/

	for {
		record, err := reader.Read()
		if err == io.EOF {
			break
		} else if err != nil {
			fmt.Println("Error:", err)
			return
		}

		if len(record) < 4 {
			fmt.Println("Error:", "record is zero, maybe it is not a cvs format!!!")
			return
		}

		var minRecord MinuteRecord
		minRecord.Time = record[0]
		minRecord.Price, err = strconv.ParseFloat(record[1], 64)
		if err != nil {
			logger.Fatalln(record)
			logger.Fatal("ParseMinuteCSV item price is not number")
		}
		minRecord.Volumn, err = strconv.ParseFloat(record[2], 64)
		if err != nil {
			logger.Fatal("ParseMinuteCSV item Volumn is not number")
		}
		minRecord.Amount, err = strconv.ParseFloat(record[3], 64)
		if err != nil {
			logger.Fatal("ParseMinuteCSV item Amount is not number")
		}

		MinuteRecords = append(MinuteRecords, minRecord)
	}

	return
}
开发者ID:kewinwang,项目名称:btcrobot,代码行数:53,代码来源:marketapi.go

示例13: marketAPI

func marketAPI() (marketAPI MarketAPI) {
	if Option["datacenter"] == "huobi" {
		marketAPI = huobi.NewHuobi()
	} else if Option["datacenter"] == "okcoin" {
		marketAPI = okcoin.NewOkcoin()
	} else if Option["datacenter"] == "peatio" {
		marketAPI = peatio.NewPeatio()
	} else if Option["datacenter"] == "bittrex" {
		marketAPI = Bittrex.Manager()
	} else {
		logger.Fatalln("Please config the market center...")
	}
	return
}
开发者ID:9cat,项目名称:btcrobot,代码行数:14,代码来源:monitor.go

示例14: tradeAPI

func tradeAPI() (tradeAPI TradeAPI) {
	if Option["tradecenter"] == "huobi" {
		tradeAPI = huobi.NewHuobi()
	} else if Option["tradecenter"] == "okcoin" {
		tradeAPI = okcoin.NewOkcoin()
	} else if Option["tradecenter"] == "bitvc" {
		tradeAPI = bitvc.NewBitvc()
	} else if Option["tradecenter"] == "peatio" {
		tradeAPI = peatio.NewPeatio()
	} else {
		logger.Fatalln("Please config the exchange center...")
	}
	return
}
开发者ID:2yeslater,项目名称:btcrobot,代码行数:14,代码来源:monitor.go

示例15: tradeAPI

func tradeAPI() (tradeAPI TradeAPI) {
	if Option["tradecenter"] == "huobi" {
		tradeAPI = huobi.NewHuobi()
	} else if Option["tradecenter"] == "okcoin" {
		tradeAPI = okcoin.NewOkcoin()
	} else if Option["tradecenter"] == "bitvc" {
		tradeAPI = bitvc.NewBitvc()
	} else if Option["tradecenter"] == "peatio" {
		tradeAPI = peatio.NewPeatio()
	} else if Option["tradecenter"] == "bittrex" {
		tradeAPI = Bittrex.Manager()
	} else if Option["tradecenter"] == "simulate" {
		tradeAPI = simulate.NewSimulate()
	} else {
		logger.Fatalln("Please config the exchange center...")
		panic(0)
	}
	return
}
开发者ID:philsong,项目名称:btcrobot,代码行数:19,代码来源:monitor.go


注:本文中的Logger.Fatalln函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。