在linux上想获取文件的元信息,我们需要使用系统调用lstat或者stat. 在golang的os包里已经把stat封装成了Stat函数,使用它比使用syscall要方便不少. 这是os.Stat的原型: func Stat(name string) (FileInfo, error) Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError. 返
在linux下想实现开机启动的方法很多,这里我采用了在/etc/rc.local里写shell指令的方式. 以下就以我的实际操作为例子讲述,很多地方需要看官自己调整信息哦! 1.在/etc/rc.local文件中,添加你想要执行的脚本. 比如,我现在要执行的是Golang项目启动的脚本: ficowLogPath="/home/ficow/autoLaunchLog.txt" #launch ficow's blog server cd /home/ficow/ficowblog/sr
uname -a Linux symons_laptop 4.8.2-1-ARCH #1 SMP PREEMPT Mon Oct 17 08:11:46 CEST 2016 x86_64 GNU/Linux 上面是我的机器 1. 下载go sudo pacman -S go //如果你在其他的发行版的话,请使用其他方式,这一步都差不多 2. 检查go版本 go version go version go1.7.3 linux/amd64 3. 安装vim插件, vim-go 我是使用bundle
1.wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz tar -zxvf go1.6.2.linux-amd64.tar.gz vim etc/profile 增加以下代码: export GOROOT=/usr/local/golang/goPATH=$PATH:$GOROOT/bin source /etc/profile 测试: go version