<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Stack Problems</title>
    <description>My Personal Stack Problems</description>
    <link>https://seamao.github.io/</link>
    <atom:link href="https://seamao.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 27 Nov 2020 03:35:28 +0000</pubDate>
    <lastBuildDate>Fri, 27 Nov 2020 03:35:28 +0000</lastBuildDate>
    <generator>Jekyll v3.9.0</generator>
    
      <item>
        <title>基于ipfs、智能合约的图片存储DAPP</title>
        <description>&lt;h2 id=&quot;开局一条狗后面全靠打&quot;&gt;开局一条“狗”,后面全靠打!&lt;/h2&gt;
&lt;hr /&gt;

&lt;center&gt; **《Dapp》**&lt;/center&gt;

&lt;p&gt;** 项目目标: **&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;结合ipfs,智能合约创建一个去中心化的图片储存查看平台.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** 项目需求: **&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;将图片存储到ipfs,通过哈希值读取图片.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** 环境依赖 **&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Linux 系统 或者 Mac 系统&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;NodeJS 安装
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;安装地址 https://nodejs.org/en/ ,具体安装不做解释了,百度有很多教程,跟着教程去做就行了
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;truffle 安装&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;truffle介绍:  &lt;br /&gt;
以太坊是区块链开发领域最好的编程平台，而truffle是以太坊
（Ethereum）最受欢迎的一个开发框架.&lt;/p&gt;

&lt;p&gt;全局安装truffle&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install -g truffle
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;MetaMask 安装&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;MetaMask是以太坊网络非常好用的钱包插件,前提是要先安装谷歌浏览器.
提醒:MetaMask是谷歌浏览器拓展程序,所以需要翻墙才能查看,不能翻墙的朋友可以直接在这个链接下载,直接拉到拓展程序,同样可以用!
&lt;img src=&quot;http://p3qaz7oyz.bkt.clouddn.com/%E8%B0%B7%E6%AD%8C%E6%8B%93%E5%B1%95%E7%A8%8B%E5%BA%8F.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;安装包：

链接: https://pan.baidu.com/s/12rumbY5xvpbr-gYtu3OoMg 密码: v958

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;ipfs 环境配置&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
区块链职业教育培训之父黎跃春已经有非常详细的安装步骤，详情可看下方链接

链接: https://pan.baidu.com/s/1LDyx9TVFPV8V8byYWFDlag 密码: 3yxb

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;以上就是一些依赖环境了&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;这里要恭喜你完成了上面最艰难的环境搭建，下面就来做我们的项目吧！&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;创建项目&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;创建一个名为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project&lt;/code&gt;的文件夹，在文件夹里面输入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;truffle unbox rect&lt;/code&gt;命令创建项目（此处新建的项目是框架完整的项目）。&lt;/p&gt;

&lt;p&gt;因为项目需要下载一些依赖包，所以时间会相对长点，具体看网速，等待就行了，我这渣渣网速需要10分钟时间。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;maohaibo@maohaibo:~/桌面$ mkdir Project
maohaibo@maohaibo:~/桌面$ cd Project/
maohaibo@maohaibo:~/桌面/Project$ truffle unbox react
Downloading...
Unpacking...
Setting up...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;下载完之后整个项目包里面的内容如下：
最主要的有几个&lt;/p&gt;

&lt;p&gt;&lt;em&gt;contracts&lt;/em&gt;  ： 我们在这里面编译智能合约&lt;/p&gt;

&lt;p&gt;&lt;em&gt;node__modules&lt;/em&gt;  ： 我们所需要的依赖包都在这里面存着&lt;/p&gt;

&lt;p&gt;&lt;em&gt;src&lt;/em&gt;  ： 我们需要在这里输入的是最多的&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://p3qaz7oyz.bkt.clouddn.com/truffle%E5%8C%85.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;编写程序&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;一、在依赖包中导入ipfs包&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;在项目目录下运行下面的命令安装  ipfs接口&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install --save-dev ipfs-api

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装完之后在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;package.json&lt;/code&gt;项目下会出现如下代码，表示安装成功&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot;dependencies&quot;: {
  &quot;dotenv&quot;: &quot;^2.0.0&quot;,
  &quot;ipfs-api&quot;: &quot;^18.1.1&quot;,
  &quot;react&quot;: &quot;^15.4.2&quot;,
  &quot;react-dom&quot;: &quot;^15.4.2&quot;
},
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;安装成功后在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project/src/utils/APP.js&lt;/code&gt;加入如下代码&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import ipfsAPI from 'ipfs-api'
const ipfs = ipfsAPI({host: 'localhost', port: '5001', protocal: 'http'})

const contractAddress = &quot;你的合约地址&quot;


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;如何获取你自己的合约地址呢？&lt;/p&gt;

&lt;p&gt;1.在项目路径下进入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;truffle&lt;/code&gt;控制台，可以得到10个公钥对应10个秘钥，还有12个单词的住一次。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;truffle develop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;2.编译合约&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;compile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;3.部署合约，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SimpleStorage:×××××××××××××××&lt;/code&gt; 后面的字符串就是你的合约地址了&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;migrate
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;二、 编译合约&lt;/p&gt;

&lt;p&gt;用下面的合约把&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project/contracts/SimpleStorage&lt;/code&gt; 路径下的代码取代掉&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pragma solidity ^0.4.19;

contract SimpleStorage {

    string[] public photoArr;

    function storePhoto(string hash) public {
        photoArr.push(hash);
    }

    function getPhoto(uint index) public view returns (uint, string){
        return (photoArr.length, photoArr[index]);
    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;三、编译js文件&lt;/p&gt;

&lt;p&gt;打开&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project/src/utils/APP.js&lt;/code&gt;文件
用下面的代码替换点文件里面的所有代码&lt;/p&gt;

&lt;p&gt;其中需要值得注意的是&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;你的合约地址&lt;/code&gt;还是要填写你自己合约地址的&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import React, {Component} from 'react'
import SimpleStorageContract from '../build/contracts/SimpleStorage.json'
import getWeb3 from './utils/getWeb3'

import './css/oswald.css'
import './css/open-sans.css'
import './css/pure-min.css'
import './App.css'

import ipfsAPI from 'ipfs-api'
const ipfs = ipfsAPI({host: 'localhost', port: '5001', protocal: 'http'})

const contractAddress = &quot;你的合约地址&quot;
let simpleStorageInstance

let saveImageOnIpfs = (reader) =&amp;gt; {
	return new Promise(function (resolve, reject) {
		const buffer = Buffer.from(reader.result);
		ipfs.add(buffer).then((response) =&amp;gt; {
			console.log(response)
			resolve(response[0].hash);
		})
		.catch((err) =&amp;gt; {
			console.error(err)
			reject(err);
		})
	})
}

class App extends Component {
	constructor(props) {
		super(props)

		this.state = {
			photos: [],
			count: 0,
			web3: null
		}
  	}

  	componentWillMount() {
    // Get network provider and web3 instance. See utils/getWeb3 for more info.

    getWeb3.then(results =&amp;gt; {
    	this.setState({web3: results.web3})
			this.instantiateContract()
		}).catch(() =&amp;gt; {
			console.log('Error finding web3.')
		})
	}

  	instantiateContract() {
		const that = this
		const contract = require('truffle-contract')
		const simpleStorage = contract(SimpleStorageContract)
		simpleStorage.setProvider(this.state.web3.currentProvider)

    	this.state.web3.eth.getAccounts((error, accounts) =&amp;gt; {
        	simpleStorage.at(contractAddress).then((instance) =&amp;gt; {
				simpleStorageInstance = instance
			})
			.then(result =&amp;gt; {
				return simpleStorageInstance.getPhoto(0)
			})
			.then(result =&amp;gt; {
				console.log(result)
				let imgNum = result[0].c[0]
				if(imgNum===0){
					return
				}
				if(imgNum===1){
					this.setState({
						count: imgNum,
						photos: this.state.photos.concat([result[1]])
					})
				}
				if(imgNum&amp;gt;1){
					for(let i=0;i&amp;lt;imgNum;i++){
						(function(i){
							simpleStorageInstance.getPhoto(i)
							.then(result =&amp;gt; {
								that.setState({
									photos: that.state.photos.concat([result[1]])
								})
							})
						})(i)
					}
				}
			})
		})
	}

  	render() {
		let doms = [],
			photos = this.state.photos
		for(let i=0; i&amp;lt;photos.length;i++){
			doms.push(&amp;lt;div key={i}&amp;gt;&amp;lt;img src={&quot;http://localhost:8080/ipfs/&quot; + photos[i]}/&amp;gt;&amp;lt;/div&amp;gt;)
		}

		return (
			&amp;lt;div className=&quot;App&quot;&amp;gt;
				&amp;lt;header&amp;gt;上传图片至ipfs，并保存信息至以太坊区块&amp;lt;/header&amp;gt;
				&amp;lt;div className=&quot;upload-container&quot;&amp;gt;
					&amp;lt;label id=&quot;file&quot;&amp;gt;选择图片&amp;lt;/label&amp;gt;
					&amp;lt;input type=&quot;file&quot; ref=&quot;file&quot; id=&quot;file&quot; name=&quot;file&quot; multiple=&quot;multip
					le&quot;/&amp;gt;
					&amp;lt;button onClick={() =&amp;gt; this.upload()}&amp;gt;上传&amp;lt;/button&amp;gt;
				&amp;lt;/div&amp;gt;
				&amp;lt;div className=&quot;img-container&quot;&amp;gt;
					{doms}
				&amp;lt;/div&amp;gt;
			&amp;lt;/div&amp;gt;
		);
	}

 	upload() {
		var file = this.refs.file.files[0];
		console.log(file)
    	var reader = new FileReader();
		// reader.readAsDataURL(file);
		reader.readAsArrayBuffer(file)
		reader.onloadend = (e) =&amp;gt; {
			//console.log(reader);
			saveImageOnIpfs(reader).then((hash) =&amp;gt; {
				console.log(hash);

					simpleStorageInstance.storePhoto(hash, {from: this.state.web3.eth.accounts[0]})
					.then(() =&amp;gt; {
						console.log(&quot;写入区块成功&quot;)
						this.setState({
							photos: this.state.photos.concat([hash])
						})
					})
			});
		}
	}

}

export default App
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;部署项目&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1、在项目路径运行 ipfs节点&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;输入：  ipfs daemon
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2、因为我们之前部署了合约地址，所以我们先删除&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build&lt;/code&gt;文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;输入： rm -rf build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;然后再重新进入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;truffle&lt;/code&gt;控制台&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1、truffle develop  //进入控制台
2、compile     //编译合约
3、migrate     //部署合约
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3、再开启一个终端，进入当前项目路径&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;输入：  npm run start

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;需要注意的是：以上3个终端需要按照顺序同时进行&lt;/em&gt;
等一会会自动跳转如下，传入图片，需要使用MetaMask&lt;/p&gt;

&lt;p&gt;等一会图片就上传上去了
&lt;img src=&quot;http://p3qaz7oyz.bkt.clouddn.com/ipfs%E4%BB%A5%E5%A4%AA%E5%9D%8A%E7%BB%93%E5%90%88.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;恭喜你，完成了一个基于智能合约,ipfs的微型DAPP,蚂蚁虽小，五脏俱全。
文章若出现跑不通的情况，请到下方留言哦！
&lt;img src=&quot;http://p3qaz7oyz.bkt.clouddn.com/%E5%85%AC%E4%BC%97%E5%8F%B7.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Sat, 10 Mar 2018 00:00:00 +0000</pubDate>
        <link>https://seamao.github.io/ipfs/dapp/2018/03/10/top-1-ipfs-libraries-of-2018.html</link>
        <guid isPermaLink="true">https://seamao.github.io/ipfs/dapp/2018/03/10/top-1-ipfs-libraries-of-2018.html</guid>
        
        
        <category>ipfs</category>
        
        <category>dapp</category>
        
      </item>
    
      <item>
        <title>1月15日总结</title>
        <description>&lt;h1 id=&quot;1月15日总结&quot;&gt;1月15日总结&lt;/h1&gt;

&lt;h3 id=&quot;问题求１０００以内的质数&quot;&gt;问题：求１０００以内的质数&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;解密质数特性：质数定义为在大于1的自然数中，除了1和它本身以外不再有其他因数。&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;package main

import &quot;fmt&quot;

func main() {

for i := 2; i &amp;lt; 999; i++ {
isZhiShu := true
//筛选　２到９９９
for k := 2; k &amp;lt; i; k++ {
if i%k == 0 {
isZhiShu = false
break
}

}

if isZhiShu {
fmt.Println(i)
}
}

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;swich-语句&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swich&lt;/code&gt; 语句　：&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swich&lt;/code&gt;如同声明一把锁，而开锁的需要&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;命令与&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swich&lt;/code&gt;内容相符，当&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;与&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;swich&lt;/code&gt;命令相符时，执行该&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;的命令，并无法执行其余&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;内容
而当&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;命令下使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fallthought&lt;/code&gt; 时，可以继续执行紧挨着的下一个&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;case&lt;/code&gt;的内容！！！&lt;/p&gt;

&lt;h3 id=&quot;输入输出对话框&quot;&gt;输入输出对话框&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;package main

import &quot;fmt&quot;

func main() {
	fmt.Print(&quot;输入一个数字：&quot;)
	score := 0
	fmt.Scanf(&quot;%d&quot;, &amp;amp;score)
	fmt.Println(score)
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;命令执行后可在终端输入相关数字回复&lt;/p&gt;

&lt;h3 id=&quot;数组&quot;&gt;数组&lt;/h3&gt;
&lt;p&gt;–　如何判断一个数组的类型&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// 如何去判断一个变量的类型

// var num int
// var v type
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;– 　遍历、快速枚举&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;for i, v := range nums {
  fmt.Println(i) //索引
  fmt.Println(v) //值
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;备注:　数组中的索引　０　表示的是数组中的第一个数的值&lt;/p&gt;

&lt;p&gt;–　切片
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mySlice := make([]int, 3, 3)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;其意为声明一个长度为３、容量为３的切片数组&lt;/p&gt;

&lt;p&gt;– append
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;append&lt;/code&gt;　可以为固定长度的数组添加值
例如：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;package main

import &quot;fmt&quot;

func main() {

	mySlice := []string{&quot;Monday&quot;, &quot;Tuesday&quot;}
	myOtherSlice := []string{&quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;}

	mySlice = append(mySlice, myOtherSlice...)

	fmt.Println(mySlice)
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;append将两个数组的值赋值给了mySlice 数组&lt;/p&gt;

&lt;p&gt;感谢观看 ! ! !&lt;/p&gt;
</description>
        <pubDate>Fri, 16 Feb 2018 00:00:00 +0000</pubDate>
        <link>https://seamao.github.io/golang/array/2018/02/16/top-1-golang-libraries-of-2018.html</link>
        <guid isPermaLink="true">https://seamao.github.io/golang/array/2018/02/16/top-1-golang-libraries-of-2018.html</guid>
        
        
        <category>golang</category>
        
        <category>array</category>
        
      </item>
    
      <item>
        <title>小奶一波Solidity工具</title>
        <description>&lt;h1 id=&quot;小奶一波solidity工具&quot;&gt;小奶一波Solidity工具&lt;/h1&gt;
&lt;blockquote&gt;
  &lt;p&gt;简介：
Solidity是编写智能合约的契约式编程语言。它用于在各种区块链平台上实施智能合约。由Gavin Wood，Christian Reitwiessner，Alex Beregszaszi，Liana Husikyan，Yoichi Hirai和几个以前的Ethereum核心撰稿人开发，可以在区块链平台（如Ethereum）上编写智能合约。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;言简意赅的来讲Solidity是一种语法类似JavaScript的高级语言。它被设计成以编译的方式生成以太坊虚拟机代码。&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;工欲善其事必先利其器，那么今天的重点也就是基础了。
我们使用什么工具？&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;atom 编译工具&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;简介：Atom可以跨操作系统使用，支持包括golang、Solidity在内的等一些语言编辑器，言简意赅：“好使。”&lt;/p&gt;

&lt;p&gt;下载链接  https://atom.io/&lt;/p&gt;

&lt;p&gt;安装成功后可以优美的双击打开，
同样也可以终端在你要打开的文件的目录下运行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;atom ./&lt;/code&gt;命令更优美的打开！&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Metamask 以太坊轻钱包&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;在这里可以把Metamask称作小狐狸，鼠标放在哪里，小狐狸的头像就会跟到哪里！&lt;/p&gt;

&lt;p&gt;Metamask属于谷歌浏览器拓展程序，所以前提是要先下载个谷歌浏览器
然后转到以下地址
https://chrome.google.com/webstore/category/extensions?hl=zh-CN&lt;/p&gt;

&lt;p&gt;此处需&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VPN&lt;/code&gt;
直接搜索&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Metamask&lt;/code&gt;添加到拓展工具，然后创建自己的账号&lt;/p&gt;

&lt;p&gt;切记：创建的过程中记录好那12个单词的助记词，因为那就是钱啊&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Solidity网页编译器&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;链接 https://remix.ethereum.org&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;atom&lt;/code&gt;上面进行编辑,Solidity网页编译器进行编译
然后呢就开启&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;智能合约&lt;/code&gt;编程之旅吧!!!&lt;/p&gt;

&lt;p&gt;来一波公众号
&lt;img src=&quot;http://p3qaz7oyz.bkt.clouddn.com/0.jpeg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Tue, 06 Feb 2018 00:00:00 +0000</pubDate>
        <link>https://seamao.github.io/solidity/%E5%B7%A5%E5%85%B7/2018/02/06/top-1-Solidity-libraries-of-2018.html</link>
        <guid isPermaLink="true">https://seamao.github.io/solidity/%E5%B7%A5%E5%85%B7/2018/02/06/top-1-Solidity-libraries-of-2018.html</guid>
        
        
        <category>Solidity</category>
        
        <category>工具</category>
        
      </item>
    
      <item>
        <title>Top 10 golang libraries of 2018</title>
        <description>&lt;h1 id=&quot;1月30日学习总结&quot;&gt;1月30日学习总结&lt;/h1&gt;

&lt;h2 id=&quot;小概念-非官方&quot;&gt;小概念　/ 非官方&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;管道&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;　若后边没有被赋值，则为非缓冲管道，反之则为缓冲管道&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;var ch chan int //创建了一个管道
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;go语法&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;在方法的前面加上go　则表示此为一个子线程，又名分线程&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;go func() {
}()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;time　方法&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;调用time方法，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;time.Sleep(time.Second)&lt;/code&gt; 表示runtime的时候休息１秒&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import (
	&quot;fmt&quot;
	&quot;time&quot;
)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Tue, 30 Jan 2018 11:34:10 +0000</pubDate>
        <link>https://seamao.github.io/python/django/2018/01/30/top-1-golang-libraries-of-2018.html</link>
        <guid isPermaLink="true">https://seamao.github.io/python/django/2018/01/30/top-1-golang-libraries-of-2018.html</guid>
        
        
        <category>python</category>
        
        <category>django</category>
        
      </item>
    
  </channel>
</rss>
