• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang ConsoleColor.Println函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: selectLanguage

func selectLanguage(maxRetry int) (int, error) {
	for i := 0; i < maxRetry; i++ {
		fmt.Printf("选择语言(select language):\r\n中文输入 %d 回车,For English press %d + Enter: ",
			publicdefine.L_Chinese+1, publicdefine.L_English+1)
		var input string
		_, err := fmt.Scanf("%s\n", &input)
		if err != nil {
			fmt.Println(err)
			fmt.Scanf("%s\n", &input)
			return -1, err
		}

		switch input {
		case strconv.Itoa(publicdefine.L_Chinese + 1):
			return publicdefine.L_Chinese, nil
		case strconv.Itoa(publicdefine.L_English + 1):
			return publicdefine.L_English, nil
		default:
			ConsoleColor.Println(ConsoleColor.C_RED, "语言选择错误(Language selection error)\r\n")
			// fmt.Println("语言选择错误(Language selection error)\r\n")
		}
	}
	ConsoleColor.Println(ConsoleColor.C_YELLOW, "ByeBye!\r\n")
	return -1, errors.New("Language selection error")
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:25,代码来源:wallet.go


示例2: pay

func (this *AccountInfoPayment) pay(src *publicdefine.StellarAccInfoDef,
	srcSeed, destAddr string, amount float64) *publicdefine.StellarPaymentInfo {
	payment := &publicdefine.StellarPaymentInfo{
		SrcInfo:    src,
		Amount:     amount,
		Destinaton: destAddr,
	}

	signed := payment.GetSigned(srcSeed)

	if len(signed) > 0 {
		data := "tx=" + url.QueryEscape(signed)
		// data, err := json.Marshal(map[string]interface{}{
		// 	"tx": signed,
		// })

		postUrl := publicdefine.STELLAR_DEFAULT_NETWORK + publicdefine.STELLAR_NETWORK_TRANSACTIONS
		ret, err := this.httppost_form(postUrl, data)
		// ret, err := this.httppost_json(postUrl, data)
		if err == nil {
			payment.PutResult(ret)
			return payment
		}
		ConsoleColor.Println(ConsoleColor.C_RED, err)
		// fmt.Println(err)
	}
	return nil
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:28,代码来源:accountInfo_payment.go


示例3: execute

func (this *CreateAccount) execute(isSync bool) {
	var input string

	kp, err := keypair.Random()

	if err == nil {
		keyp := kp.(*keypair.Full)
		fmt.Printf("\r\n"+this.infoStrings[this.languageIndex][CA_INFO_SECRET_SEED]+" %s\r\n", keyp.Seed())
		fmt.Printf(this.infoStrings[this.languageIndex][CA_INFO_PUBLIC_ADDR]+" %s\r\n", keyp.Address())
		fmt.Printf("\r\n" + this.infoStrings[this.languageIndex][CA_INFO_MEMO_TEXT])
		fmt.Scanf("%s\n", &input)

		if input == "s" {
			err = this.savefile("account_info.txt", keyp.Seed(), keyp.Address())
			if err == nil {
				ConsoleColor.Printf(ConsoleColor.C_YELLOW,
					"\r\n"+this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE]+"\r\n\r\n", "account_info.txt")
				// fmt.Printf("\r\n"+this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE]+"\r\n\r\n", "account_info.txt")
			} else {
				ConsoleColor.Println(ConsoleColor.C_RED,
					"\r\n", this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE_ERR], "\r\n", err, "\r\n\r\n")
				// fmt.Println("\r\n", this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE_ERR], "\r\n", err, "\r\n\r\n")
			}
		}
	} else {
		fmt.Println(err.Error())
		fmt.Scanf("%s\n", &input)
	}

	if !isSync {
		this.ASyncChan <- 0
	}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:33,代码来源:NewAccount.go


示例4: quary

func (this *AccountInfoOperationQuary) quary(addr string) {
	result := &publicdefine.StellarAccOperationQuary{
		QuaryCursor: "",
		IsEnd:       false,
	}
	for {
		ConsoleColor.Print(ConsoleColor.C_BLUE,
			this.infoStrings[this.languageIndex][AIOQ_INFO_QUARY_WAITING])

		reqUrl := fmt.Sprintf("%s%s/%s/%s?order=desc&limit=%d&cursor=%s", publicdefine.STELLAR_DEFAULT_NETWORK,
			publicdefine.STELLAR_NETWORK_ACCOUNTS, addr,
			publicdefine.STELLAR_NETWORK_OPERATIONS, 10, result.QuaryCursor)
		resMap, err := this.httpget(reqUrl)

		if err == nil {
			result.PutMapBody(resMap)
			this.PrintResult(result)
		} else {
			ConsoleColor.Println(ConsoleColor.C_RED, err)
			break
		}

		if result.IsEnd {
			break
		}
		if this.input_next() != "n" {
			break
		}
	}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:30,代码来源:accountInfo_operation_quary.go


示例5: merging

func (this *MergeAccount) merging(srcInfo *publicdefine.StellarAccInfoDef, srcSeed, destAddr string) *publicdefine.StellarAccountMerge {
	mergeInfo := &publicdefine.StellarAccountMerge{
		SrcInfo:        srcInfo,
		DestPublicAddr: destAddr,
	}

	signed := mergeInfo.GetSigned(srcSeed)

	if len(signed) > 0 {
		data := "tx=" + url.QueryEscape(signed)
		// data, err := json.Marshal(map[string]interface{}{
		// 	"tx": signed,
		// })

		postUrl := publicdefine.STELLAR_DEFAULT_NETWORK + publicdefine.STELLAR_NETWORK_TRANSACTIONS
		ret, err := this.httppost_form(postUrl, data)
		if err == nil {
			mergeInfo.PutResult(ret)
			return mergeInfo
		}
		ConsoleColor.Println(ConsoleColor.C_RED, err)
		// fmt.Println(err)
	}
	return nil
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:25,代码来源:mergeaccount.go


示例6: getProxyClient

func getProxyClient(proxyIP, proxyPort string, auth ...*proxy.Auth) *http.Client {

	proxyurl := proxyIP + ":" + proxyPort
	var author *proxy.Auth = nil
	if auth != nil {
		author = auth[0]
	}
	dialer, err := proxy.SOCKS5("tcp", proxyurl, author,
		&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
		},
	)

	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** Socket5ProxyClient() Error\r\n\t", "proxy.SOCKS5: ", err)
		return nil
	}

	transport := &http.Transport{
		Proxy:               nil,
		Dial:                dialer.Dial,
		TLSHandshakeTimeout: 10 * time.Second,
	}

	return &http.Client{Transport: transport}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:27,代码来源:httpget.go


示例7: create_account

func (this *AccountInfoPayment) create_account(src *publicdefine.StellarAccInfoDef,
	srcSeed, destAddr string, amount float64) bool {

	if len(this.inputConfirm(destAddr)) == 0 {
		ConsoleColor.Println(ConsoleColor.C_RED,
			this.infoStrings[this.languageIndex][AIP_INFO_PAYMENT_ABORT])
		return false
	}

	ConsoleColor.Printf(ConsoleColor.C_BLUE,
		this.infoStrings[this.languageIndex][AIP_INFO_CREATE_DEST_ADDR], destAddr)

	if amount < 20 {
		ConsoleColor.Println(ConsoleColor.C_RED,
			this.infoStrings[this.languageIndex][AIP_INFO_PAYMENT_ABORT_LESS20])
		return false
	}

	cAcc := publicdefine.StellarAccountCreateInfo{
		SrcInfo:    src,
		Amount:     amount,
		Destinaton: destAddr,
	}

	signed := cAcc.GetSigned(srcSeed)

	if len(signed) > 0 {
		data := "tx=" + url.QueryEscape(signed)

		postUrl := publicdefine.STELLAR_DEFAULT_NETWORK + publicdefine.STELLAR_NETWORK_TRANSACTIONS
		ret, err := this.httppost_form(postUrl, data)
		// ret, err := this.httppost_json(postUrl, data)
		if err == nil {
			cAcc.PutResult(ret)
			if len(cAcc.ResultHash) > 0 {
				ConsoleColor.Println(ConsoleColor.C_BLUE,
					this.infoStrings[this.languageIndex][AIP_INFO_CREATE_DEST_ADDR_SUCCESS])
				return true
			}
		}
		ConsoleColor.Println(ConsoleColor.C_RED, err)
		// fmt.Println(err)
	}
	ConsoleColor.Println(ConsoleColor.C_RED,
		this.infoStrings[this.languageIndex][AIP_INFO_CHECK_TRANSACTION_ERROR])
	return false
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:47,代码来源:accountInfo_payment.go


示例8: HttpGet

func HttpGet(geturl string) (map[string]interface{}, error) {
	resp, err := http.Get(geturl)
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, "ERROR [ HTTPGet() ]\r\n\t", "Get: ", err)
		return nil, err
	}
	return getResponseDecode(resp)
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:8,代码来源:httpget.go


示例9: PrintResult

func (a *AccountInfoOperationQuary) PrintResult(r *publicdefine.StellarAccOperationQuary) {
	fmt.Print("\r")
	for i := 0; i < len(r.Records); i++ {
		ConsoleColor.Printf(ConsoleColor.C_GREEN,
			" %02d --------------------------------------------------------------------------------\r\n", i+1)

		ConsoleColor.Println(ConsoleColor.C_BLUE,
			r.Records[i].ToString(), "\r\n\r\n")
	}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:10,代码来源:accountInfo_operation_quary.go


示例10: execute

func (this *MergeAccount) execute(isSync bool) {
	fmt.Println("")
	var isError bool = true
	var srcAddr, srcSeed, destAddr string
	for i := 0; i < 5; i++ {
		switch i {
		case 0:
			srcAddr = this.input_SrcAddr()
			isError = len(srcAddr) == 0
		case 1:
			srcSeed = this.input_SrcSeed()
			isError = len(srcSeed) == 0
		case 2:
			destAddr = this.input_DestAddr()
			isError = len(destAddr) == 0
		case 3:
			ConsoleColor.Printf(ConsoleColor.C_BLUE,
				this.infoStrings[this.languageIndex][MA_INFO_CONFIRM_INFOS], srcAddr, destAddr)
			// fmt.Printf(this.infoStrings[this.languageIndex][MA_INFO_CONFIRM_INFOS], srcAddr, destAddr)
			confirm := this.input_Confirm()
			if confirm != "yes" {
				i = 5
				ConsoleColor.Println(ConsoleColor.C_YELLOW,
					this.infoStrings[this.languageIndex][MA_INFO_OPERATION_BREAK])
				// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_OPERATION_BREAK])
			}
		case 4:
			this.beginMerge(srcAddr, srcSeed, destAddr)
		}

		if isError {
			ConsoleColor.Println(ConsoleColor.C_RED,
				this.infoStrings[this.languageIndex][MA_INFO_ADDR_FORMAT_ERR])
			// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_ADDR_FORMAT_ERR])
			break
		}
	}

	if !isSync {
		this.ASyncChan <- 0
	}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:42,代码来源:mergeaccount.go


示例11: HttpPost_form

func HttpPost_form(address, data string) (map[string]interface{}, error) {

	resp, err := http.Post(address,
		"application/x-www-form-urlencoded", strings.NewReader(data))
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** HTTPPost() Error\r\n\t", "Post: ", err)
		return nil, err
	}

	return getResponseDecode(resp)
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:11,代码来源:httpget.go


示例12: HttpPost_json

func HttpPost_json(address string, data []byte) (map[string]interface{}, error) {

	resp, err := http.Post(address,
		"application/json", strings.NewReader(string(data)))
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, "ERROR [ HTTPPOST.json() ]\r\n\t", "Post: ", err)
		return nil, err
	}

	return getResponseDecode(resp)
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:11,代码来源:httpget.go


示例13: SPrintWarning

func SPrintWarning(title, format string, v ...interface{}) (ret string) {
	ret = fmt.Sprintf("[ %s ]\r\n\t", title)
	if v == nil {
		ret += fmt.Sprintf(format)
	} else {
		ret += fmt.Sprintf(format, v)
	}
	if LogLevelConfig.Warning {
		ConsoleColor.Println(ConsoleColor.C_BLUE, time.Now().Format("2006-01-02 15:04:05")+" [W] "+ret)
	}
	return
}
开发者ID:Ledgercn,项目名称:go-LumenFederation,代码行数:12,代码来源:logger.go


示例14: HttpProxyGet

func HttpProxyGet(pgUrl, proxyIP, proxyPort string, auth ...*proxy.Auth) (map[string]interface{}, error) {

	client := getProxyClient(proxyIP, proxyPort, auth...)

	resp, err := client.Get(pgUrl)
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** HTTPProxyGet() Error\r\n\t", "Get: ", err)
		return nil, err
	}

	return getResponseDecode(resp)
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:12,代码来源:httpget.go


示例15: beginMerge

func (this *MergeAccount) beginMerge(srcAddr, srcSeed, destAddr string) {
	ConsoleColor.Println(ConsoleColor.C_BLUE,
		this.infoStrings[this.languageIndex][MA_INFO_CHECK_SOURCE_ACCOUNT])
	// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_CHECK_SOURCE_ACCOUNT])
	// 先检查账户是不是存在
	srcInfo := this.checkSourceAddr(srcAddr)
	if srcInfo == nil {
		return
	}
	// 检查Seed和Public Addr是不是匹配
	if this.checkSeed(srcSeed, srcAddr) == false {
		return
	}

	ConsoleColor.Println(ConsoleColor.C_BLUE,
		this.infoStrings[this.languageIndex][MA_INFO_MERGING])
	// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_MERGING])

	mergeInfo := this.merging(srcInfo, srcSeed, destAddr)
	if mergeInfo == nil {
		ConsoleColor.Println(ConsoleColor.C_RED,
			this.infoStrings[this.languageIndex][MA_INFO_MERGING_ERR])
		// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_MERGING_ERR])
		return
	}

	// 检查transaction hash是否生效
	if len(mergeInfo.ResultHash) == 0 {
		ConsoleColor.Println(ConsoleColor.C_RED,
			this.infoStrings[this.languageIndex][MA_INFO_MERGING_FIAL])
		// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_MERGING_FIAL])
		return
	}

	ConsoleColor.Println(ConsoleColor.C_GREEN,
		this.infoStrings[this.languageIndex][MA_INFO_MERGE_COMLETE])
	// fmt.Println(this.infoStrings[this.languageIndex][MA_INFO_MERGE_COMLETE])

}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:39,代码来源:mergeaccount.go


示例16: HttpProxyPost_form

func HttpProxyPost_form(address, data, proxyIP, proxyPort string, auth ...*proxy.Auth) (map[string]interface{}, error) {

	client := getProxyClient(proxyIP, proxyPort, auth...)

	resp, err := client.Post(address,
		"application/x-www-form-urlencoded", strings.NewReader(data))
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** HTTPProxyPost() Error\r\n\t", "Post: ", err)
		return nil, err
	}

	return getResponseDecode(resp)
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:13,代码来源:httpget.go


示例17: checkSeed

func (this *MergeAccount) checkSeed(seed, srcAddr string) bool {
	pk, err := keypair.Parse(seed)
	if err == nil {
		if pk.Address() == srcAddr {
			return true
		}
		ConsoleColor.Printf(ConsoleColor.C_RED,
			this.infoStrings[this.languageIndex][MA_INFO_SEED_AND_ADDR_IS_NOT_PAIR]+"\r\n")
		// fmt.Printf(this.infoStrings[this.languageIndex][MA_INFO_SEED_AND_ADDR_IS_NOT_PAIR] + "\r\n")
	} else {
		ConsoleColor.Println(ConsoleColor.C_RED, err)
		// fmt.Println(err)
	}
	return false
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:15,代码来源:mergeaccount.go


示例18: execute

func (this *AccountInfoBase) execute(isSync bool) {
	fmt.Println(this.infoStrings[this.languageIndex][AIB_INFO_INPUT_ADDR])

	var input string

	_, err := fmt.Scanf("%s\n", &input)
	if err == nil {
		addrs := strings.Split(input, ",")
		addrs = this.checkAddrs(addrs)
		fmt.Println("\r\n")
		length := len(addrs)
		for i := 0; i < length; i++ {
			ret, err := this.getAccountInfo(addrs[i])
			if err == nil {
				ConsoleColor.Println(ConsoleColor.C_GREEN, " ..........................................................................  ")

				ConsoleColor.Println(ConsoleColor.C_BLUE, ret.ToString(), "\r\n\r\n")
			}
		}
	}
	if !isSync {
		this.ASyncChan <- 0
	}
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:24,代码来源:accountInfo_base.go


示例19: getResponseDecode

func getResponseDecode(resp *http.Response) (map[string]interface{}, error) {

	if resp == nil {
		return nil, errors.New("http.Response is nil!")
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** HTTP Response ERROR\r\n\t", "ReadAll: ", err)
		return nil, err
	}

	// fmt.Println("[ HTTPGet().body ]\r\n\t", string(body))

	result := make(map[string]interface{})
	err = json.Unmarshal(body, &result)
	if err != nil {
		ConsoleColor.Println(ConsoleColor.C_RED, " ** HTTP Response ERROR\r\n\t", "Unmarshal: ", err)
		return nil, err
	}

	return result, nil
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:24,代码来源:httpget.go


示例20: checkPublicAddrExist

func (this *AccountInfoPayment) checkPublicAddrExist(addr string) *publicdefine.StellarAccInfoDef {
	reqUrl := publicdefine.STELLAR_DEFAULT_NETWORK + publicdefine.STELLAR_NETWORK_ACCOUNTS + "/" + addr
	resMap, err := this.httpget(reqUrl)

	if err == nil {
		ret := &publicdefine.StellarAccInfoDef{}
		ret.PutMapBody(addr, resMap)
		if ret.IsExist() {
			return ret
		}
	} else {
		ConsoleColor.Println(ConsoleColor.C_RED, err)
		// fmt.Println(err)
	}
	return nil
}
开发者ID:zzj882,项目名称:go-StellarWallet,代码行数:16,代码来源:accountInfo_payment.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang errors.Trace函数代码示例发布时间:2022-05-23
下一篇:
Golang info.User类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap