This is a created article in which the information may have evolved or changed.
Package Mainimport ("FMT" "Net/http") Func Indexhandler (w http. Responsewriter, R *http. Request) {r.parseform () fmt. Println (R.url. Path) W.write ([]byte ("" Hello "))}func Main () {http. Handlefunc ("/", Indexhandler) Err: = http. Listenandserve (": 9090", nil) if err! = Nil {fmt. PRINTLN (ERR)}}
A simple web site that was tried after learning Golang
We see the above code, to write a Web server compared to other languages is much simpler, just need to invoke the HTTP packet two function is OK
Do not like php,jsp is very troublesome, JSP also to deploy code on the server, go does not need to do this should go directly to listen to the TCP port, do the nginx do things
Indexhandler is a function, similar to a controller in a JSP.
Golang Invoking system commands
Http://stackoverflow.com/questions/6182369/exec-a-shell-command-in-go