标签:style http color ar strong sp div c on
下载地址:
http://golang.so/dl/go1.3.windows-amd64.msi
http://golang.so/dl/go1.3.windows-386.msi
http://golang.so/dl/go1.3.linux-amd64.tar.gz
http://golang.so/dl/go1.3.linux-386.tar.gz
代码编辑工具可选择goeclipse,LiteIDE或者文本编辑器+插件.
helloWorld.go |
package main
import ( "fmt" )
func main() { fmt.Println("Hello,世界!") } |
>>go run helloWorld.go Hello,世界! |
simpleWebServer.go |
package main
import ( "net/http" "fmt" )
// Default Request Handler func defaultHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "<h1>Hello %s!</h1>", r.URL.Path[1:]) }
func main() { http.HandleFunc("/", defaultHandler) http.ListenAndServe(":8080", nil) } |
>>go run simpleWebServer.go >>curl http://127.0.0.1:8080/世界 <h1>Hello 世界!</h1> |
标签:style http color ar strong sp div c on
原文地址:http://www.cnblogs.com/huligong1234/p/4003293.html