Golang Exec 调用外部程序 | KaiQ.Gu|KerwinKoo Blog

作者:JerryXia | 发表于 , 阅读 (0)
用法e.g.
import ""os/exec""1234567func FetchDefaultTemplate() { cmd := exec.Command("git", "clone", "--depth=1", "https://github.com/mengzhuo/bla_default_template.git") if err := cmd.Start(); err != nil { log.Fatal(err) } cmd.Wait()}cmd.start()官方说明:
123456// Start starts the specified command but does not wait for it to complete.//// The Wait method will return the exit code and release associated resources// once the command exits.func (c *Cmd) Start() error关于cmd.Wait()的官方说明:
1234567891011121...阅读全文

Golang File IO Operations | KaiQ.Gu|KerwinKoo Blog

作者:JerryXia | 发表于 , 阅读 (0)
1 Read File into []byte in Package:ioutil12345678910111213141516func readFileIntoByte(filename string) []byte { var fmwConfigJsonBuf []byte fin, err := os.Open(filename) if err != nil { panic(err) } else { fmwConfigJsonBuf, err = ioutil.ReadAll(fin) if err != nil { panic(err) } } fin.Close() return fmwConfigJsonBuf}2  File Copy1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859// CopyFile copies a file from src to dst. If src and ds...阅读全文

翻译:Principled Design of the Modern Web Architecture | KaiQ.Gu|KerwinKoo Blog

作者:JerryXia | 发表于 , 阅读 (0)
前言:REST 表征状态传输(英文:Representational State Transfer,简称REST)是Roy Fielding博士于2000年在他的博士论文中提出来的一种软件架构风格。两年后,Roy Fielding和Richard N. Taylor署名发表论文Principled Design of the Modern Web Architecture,系统介绍了REST Web Architecture在现代Web架构环境下扮演的角色和作用,蕴含REST设计思想及原则。本人以有限的英文水平对此论文进行中文翻译。关于论文标题 Principled Design of the Modern Web Architecture,本译文中将其翻译为 关于现代Web架构的原则性设计,因为“原则性”代表约束性,RESTful本身是一种Web设计风格,是对Web架构设计的约束的抽象体现。
Translator: Kerwin Koo正文:Title: Principled Design of the Modern Web ArchitectureAuthor: Roy T. F...阅读全文

GoGetTools 问题解决 | KaiQ.Gu|KerwinKoo Blog

作者:JerryXia | 发表于 , 阅读 (0)
在编译HUGO时遇到的问题。
报错信息:
hugolib/site.go:33:2: cannot find package "bitbucket.org/pkg/inflect" in any of:{GOPATH}
意思是当前的工程缺少import包文件。但我是通过go get直接在github中获取到本地的,原则上不会缺少包丢失的情况,因此问题定位在go get过程包获取不完整。
重新go get发现报错信息:
go: missing Mercurial command. See https://golang.org/s/gogetcmdpackage bitbucket.org/pkg/inflect: exec: "hg": executable file not found in $PATH说的很明白,无法执行命令hg,是因为缺少Mercurial command。
解决方案,安装Mercurial:
sudo apt-get install mercurial另外go get提示中也提到了获取missing command的介绍:https://golang...阅读全文