wget https://github.com/silenceshell/hcache/archive/master.zip
unzip master
hcache要求go的版本不得低于1.4.本次使用go1.7
wget https://dl.google.com/go/go1.7.6.linux-amd64.tar.gz
tar zxvf go1.7.6.linux-amd64.tar.gz
mv go /usr/local
vi ~/.bash_profile
添加如下语句:
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
而后执行: source ~/.bash_profile即可。
cd hcache_master
export GO_PATH = {hcache_master的路径}
go get github.com/tobert/pcstat
此时可能会报如下错误:
正克隆到 '/home/sys_test/hcache-master/src/github.com/tobert/pcstat'...
fatal: unable to access 'https://github.com/tobert/pcstat/': SSL connect error
package github.com/tobert/pcstat: exit status 128
需要设置:
git config --global url.git://github.com/.insteadOf https://github.com/
此时再次执行: go get github.com/tobert/pcstat
可能会有如下错误:
package golang.org/x/sys/unix: unrecognized import path "golang.org/x/sys/unix" (https fetch: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
网络问题,还好能通过github下载:
解决方法如下:
go get github.com/golang/sys/unix
此时可能会报如下错误:
package github.com/golang/sys/unix: code in directory /home/sys_test/hcache-master/src/github.com/golang/sys/unix expects import "golang.org/x/sys/unix"
cd {hcache_master的路径}/src
mkdir -p golang.org/x/
mv github.com/golang/sys golang.org/x/
rm -rf github.com/golang/
以上准备步骤就ok了,此时执行
go build
在: {hcache_master的路径}下就能看到生成了hcache_master的可执行文件。执行hcache_master文件。
如果出现如下结果,表明安装成功:
/hcache-master
Usage of ./hcache-master:
-bname
convert paths to basename to narrow the output
-histo
print a simple histogram instead of raw data
-json
return data in JSON format
-nohdr
omit the header from terse & text output
-pid int
show all open maps for the given pid
-plain
return data with no box characters
-pps
include the per-page status in JSON output
-terse
show terse output
-top int
show top x cached files
-unicode
return data with unicode box characters
全文完。
参考:
hcache git主页: https://github.com/silenceshell/hcache
pcstat git主页: https://github.com/tobert/pcstat
git无法访问的问题解决:https://github.com/bower/bower/issues/2288
升级git1.7到2.1 https://www.cnblogs.com/qingchen1984/p/5313368.html
golang.org无法访问的问题:https://blog.csdn.net/qq_35191331/article/details/79655839