exit _ golang

摘要: Use os.Exit to immediately exit with a given statuspackage mainimport ( "fmt" "os")func main() { defer fmt.Println("!") os.Exit(3)}exit st... 阅读全文
posted @ 2015-04-02 13:20 xjk112 阅读(217) 评论(0) 推荐(0) 编辑

signals _ golang

摘要: Sometimes we'd like our Go programs to intelligently handle Unix signals. For example, we might want a server to gracefully shutdown when it receives ... 阅读全文
posted @ 2015-04-02 13:16 xjk112 阅读(222) 评论(0) 推荐(0) 编辑

execing process _ golang

摘要: In the previous example we looked at spawning external processes. We do this when we need an external process accessible to running Go process. Someti... 阅读全文
posted @ 2015-04-01 13:23 xjk112 阅读(280) 评论(0) 推荐(0) 编辑

Spawning process _ golang

摘要: Sometimes our Go programs need to spawn other, non-Go process. For example, the syntax highlighting on this site is implemented by spawning a pygmenti... 阅读全文
posted @ 2015-04-01 13:17 xjk112 阅读(282) 评论(0) 推荐(0) 编辑

environment variables _ golang

摘要: Environment variables are a univerial mechanism for conveying configuration information to Unix programs. Let's look at how to set, get, and list envi... 阅读全文
posted @ 2015-04-01 13:05 xjk112 阅读(272) 评论(0) 推荐(0) 编辑

common-line flags _ golang

摘要: Command-line flags are a common way to specify options for command-line programs. For eample, in wc -l the -l is a command-line flagpackage mainimport... 阅读全文
posted @ 2015-03-31 13:30 xjk112 阅读(232) 评论(0) 推荐(0) 编辑

command-line arguments _ golang

摘要: Command-line arguments are a common way to parameterize execution of programs. For example, go run hello.go uses run and hello.go arguments to the go ... 阅读全文
posted @ 2015-03-31 13:22 xjk112 阅读(724) 评论(0) 推荐(0) 编辑

line filters _ golang

摘要: A line filter is a common type of program that reads input on stdin, processes it, and then prints some derived result to stdout. grep and sed are com... 阅读全文
posted @ 2015-03-31 13:16 xjk112 阅读(265) 评论(0) 推荐(0) 编辑

writing files _ golang

摘要: Writing files in Go follows similar patterns to the ones we saw earlier for readingpackage mainimport ( "bufio" "fmt" "io/ioutil" "os")fun... 阅读全文
posted @ 2015-03-30 13:46 xjk112 阅读(209) 评论(0) 推荐(0) 编辑

Reading files _ golang

摘要: Reading and writing files are basic tasks needed for many Go programs. First we'll look at some examples of reading filespackage mainimport ( "bufi... 阅读全文
posted @ 2015-03-30 13:39 xjk112 阅读(214) 评论(0) 推荐(0) 编辑