go

string to big Int in Go?

喜欢而已 提交于 2020-12-01 06:15:29
问题 Is there a way to convert a string (which is essentially a huge number) from string to Big int in Go? I tried to first convert it into bytes array array := []byte(string) Then converting the array into BigInt. I thought that worked, however, the output was different than the original input. So I'm guessing the conversion didn't do the right thing for some reason. The numbers I'm dealing with are more than 300 digits long, so I don't think I can use regular int. Any suggestions of what is the

Web3极客日报 #339

吃可爱长大的小学妹 提交于 2020-11-30 23:32:47
微信不支持外部链接,可以点击文章底部的 阅读原文 ,方便阅读文中的链接, 也可通过 http://daily.rebase.network/ 浏览每期日报内容。 1. 反编译以太坊智能合约 @Gala https://medium.com/coinmonks/decompiling-ethereum-smart-contracts-b283ae80f8a0 智能合约以16进制存储在以太坊中并执行,但对于去中心化的应用来说公开合约是获取信任的方式,当Dapp未公开我们可以反编译来对合约进行验证,本文介绍几种反编译方式,感兴趣可以了解下。 2. 部署去中心化网站 @Gala https://towardsdatascience.com/decentralizing-your-website-f5bca765f9ed 想象一下如果你的网站静态资源存放在中心化节点中,你的网站crash的概率,而且带宽的费用将急剧下降,虽然当前去中心化存储还在发展但不妨碍你去了解它,文章介绍如何去中心化部署你的网站。 3. Go和JavaScript的Wasm性能对比 @Gala https://medium.com/vacatronics/webassembly-in-go-vs-javascript-a-benchmark-6deb28f24e9d Wasm越来越热,大家都开始试用、尝鲜

选题 Scrum立会报告+燃尽图 04

心已入冬 提交于 2020-11-30 21:52:45
本次作业要求参见:edu.cnblogs.com/campus/nenu/2019fall/homework/9913 一、小组情况 组长:贺敬文 组员:彭思雨 王志文 位军营 徐丽君 队名:胜利点 二、Scrum例会 时间:2019年11月3日 本次Scrum Master:贺敬文 要求1 工作照片 要求2 时间跨度 2019年11月3日 21:20 至 2019年11月3日 21:55 共计 35分钟 要求3 地点 东北师范大学一食堂一楼门口 要求4 立会内容包括: (1)上周的成绩 1.总结alpha阶段团队合作需要改进的地方。 2.分析代码寻找bug。 (2)今天的计划 1.商讨如何让界面更加友好。 2.商讨如何优化代码。 (3)目前的困难 1.怎样使界面用户友好。 2.怎么让光标跳转,规则是什么。 要求5 todo list 任务ID 任务 任务执行人 截止日期 状态 1 确定每日会议master与例会时间地点 王志文 10月31日23:00 已完成 2 分配master人员 徐丽君 10月31日23:00 已完成 3 分配本周项目任务 彭思雨 10月31日23:00 已完成 4 1 0月31日Scrum立会报告加燃尽图 王志文 10月31日23:00 已完成 5 11月1日Scrum立会报告加燃尽图 彭思雨 11月1日 23:00 已完成 6

golang 内存池

拥有回忆 提交于 2020-11-30 21:51:14
一般来说,内存池都是采用预分配的方式,分为固定大小的和非固定大小块,固定大小的内存效率高,非固定大小灵活。同时,分为单线程和多线程版的,单线程不需要考虑并发问题。 一般内存池的实现思想:分配一块比较大多内存,把这块内存分成大小相等的块,即固定大小,第一块要保存必要的信息,比如nfirst(第一块可分配到块),nsize(共分配了多少),nfree(可分配块大小),pnext(若是内存池不够,分配一块growth,pnext指向下一块),p(保存第一可分配内存块的地址),同时还需要poolmanage来统一做管理。每一个内存块的头两个字节记录下一个可分配的内存块的地址,因为是固定大小的,所以可以根据p和第几块算出地址。头两个字节分配的好处就是分配之后内存可复用,注意在归还到内存池的时候头两个字节也是需要记录下一个可分配的内存块地址。 这就是内存池的思想,好了,其实今天的主题不是内存池,而是另外一种内存管理的方法,按照块的大小来分配: type bys_i struct { E * list. Element T int64 } type ByteSlice struct { P * BytePool size_ int ls_ * list. List ls_m_ map[ interface{}]*bys_i ls_l sync. RWMutex zero_ *list.

go安装及使用

纵饮孤独 提交于 2020-11-30 20:55:25
一、安装 Windows直接使用 MSI installer . 默认安装目录为 C:\Go,回自动配置好环境变量。 并默认设置工作目录为:C:\Users\用户名\go 二、使用 在默认的工作目录下: 新建一个文件夹 src/go_code,编写程序 hello.go。 package main import "fmt" func main() { fmt.Println( "Hello, World!" ) } 然后使用go工具构建程序,并运行: PS C:\Users\ 20928 \go\src\go_code> go build PS C:\Users\ 20928 \go\src\go_code> .\go_code Hello, World ! 也可以直接运行: PS C:\Users\ 20928 \go\src\go_code> go run hello.go Hello, World ! 除此之外,你可以使用 go install 将二进制文件安装到bin目录下或者使用go clean -i 来移除它。 如何在VS Code中配置go环境: https://www.jianshu.com/p/6293503522bc 如何写Go Code: https://golang.org/doc/code.html 在线编译器: https://golang.org/

Can Go really be that much faster than Python?

我只是一个虾纸丫 提交于 2020-11-30 03:53:51
问题 I think I may have implemented this incorrectly because the results do not make sense. I have a Go program that counts to 1000000000: package main import ( "fmt" ) func main() { for i := 0; i < 1000000000; i++ {} fmt.Println("Done") } It finishes in less than a second. On the other hand I have a Python script: x = 0 while x < 1000000000: x+=1 print 'Done' It finishes in a few minutes. Why is the Go version so much faster? Are they both counting up to 1000000000 or am I missing something? 回答1:

Can Go really be that much faster than Python?

旧城冷巷雨未停 提交于 2020-11-30 03:52:26
问题 I think I may have implemented this incorrectly because the results do not make sense. I have a Go program that counts to 1000000000: package main import ( "fmt" ) func main() { for i := 0; i < 1000000000; i++ {} fmt.Println("Done") } It finishes in less than a second. On the other hand I have a Python script: x = 0 while x < 1000000000: x+=1 print 'Done' It finishes in a few minutes. Why is the Go version so much faster? Are they both counting up to 1000000000 or am I missing something? 回答1:

C# 阻塞队列(Block Queue)实现

杀马特。学长 韩版系。学妹 提交于 2020-11-30 02:38:57
C#实现的阻塞队列,功能类似GO里的channel。 public class CBlockQueue<T> { private readonly Queue<T> queue = new Queue<T>(); private readonly int maxSize; bool closing; /// <summary> /// CBlockQueue init /// </summary> /// <param >maxSize</param> public CBlockQueue(int maxSize) { this.maxSize = maxSize; } /// <summary> /// Enqueue /// </summary> /// <param >item</param> public void Enqueue(T item) { lock (queue) { while (queue.Count >= maxSize) { Monitor.Wait(queue); } queue.Enqueue(item); if (queue.Count == 1) { // wake up any blocked dequeue Monitor.PulseAll(queue); } } } /// <summary> /// TryDequeue /// <

Prometheus+alertmanager监控报警示例

不羁岁月 提交于 2020-11-30 01:24:27
Alertmanager 主要用于接收 Prometheus 发送的告警信息,它支持丰富的告警通知渠道,而且很容易做到告警信息进行去重,降噪,分组,策略路由,是一款前卫的告警通知系统。 安装alertmanager #安装go 1.11 $ wget https://studygolang.com/dl/golang/go1.11.linux-amd64.tar.gz $ tar zxvf go1.11.linux-amd64.tar.gz && mv go1.11 /opt/go $ vi /etc/profile 添加 export GOROOT=/opt/go export PATH=$GOROOT/bin:$PATH export GOPATH=/opt/go-project export PATH=$PATH:$GOPATH/bin $ source /etc/profile $ go version #安装alertmanager(或者使用tar包安装) $ git clone https://github.com/prometheus/alertmanager.git $ cd alertmanager/ $ make build 安装成功以后,便可编辑报警配置文件了 配置文件为alertmanager.yml,默认如下所示 global: resolve

Ubuntu18.04配Hyperledger Fabric1.4环境

时间秒杀一切 提交于 2020-11-30 01:00:47
Hyperledger Fabric1.4配环境 Ubuntu18.04配Hyperledger Fabric1.4环境 参照官方文档(比较容易失败) 自己整理(从此处开始) 安装git和vim 安装docker 安装Go node和npm安装 拉取fabric源码 拉取镜像 下载可执行二进制文件 几个链码例子的位置(Go) Ubuntu18.04配Hyperledger Fabric1.4环境 参照官方文档(比较容易失败) 查看docker版本(是否安装) 具体安装步骤可以百度。 docker --version docker-compose --version 安装Go,并且配置环境变量。 环境变量在 /etc/profile ,末尾加上一点东西。 export GOPATH = $HOME /go export PATH = $PATH : $GOPATH /bin 安装nodejs(这一步不稳定) npm install npm@5.6.0 -g 安装python sudo apt-get install python 下面的不好成功,需要稳定的VPN 安装最新版的hyfa镜像(现在版本应该是2.0) curl -sSL http://bit.ly/2ysbOFE | bash -s 制定安装1.4.3版本的镜像 curl -sSL http://bit.ly