This is a creation in Article, where the information may have evolved or changed.
The Android SDK document is very slow to open and does not support searching. Therefore, it is necessary to build a static server locally. The following is a reference to the resources of other blogs, thanks to the author.
First, build a static server I write programs like to use HTML to send JSON requests to backend processing via Ajax. The Httpserver.go code is as follows:
package mainimport ( "Flag" "Io/ioutil" "Log" "Net/http" "OS" "Strings") Var realpath *stringfunc staticresource (w http. Responsewriter, r *http. Request) { path := r.url. Path request_type := path[strings. LastIndex (path, "."):] switch request_type { case ". css": w.header (). Set ("Content-type", "Text/css") case ". js": w.header (). Set ("Content-type", "Text/javascript") default: } fin, err := os. Open (*realpath + path) defer fin. Close () if err != nil { log. Fatal ("Static resource:", err) } fd, _ := ioutil. ReadAll (Fin) w.write (FD)}func main () { realpath = flag. String ("Path", " ", " Static resource path ") flag. Parse () http. Handlefunc ("/", staticresource) err := http. Listenandserve (": 8080", nil) if err != nil { log. Fatal ("Listenandserve:", err) } }
The more BT method:
Package Mainimport ("Net/http") func Main () {http. Handle ("/", HTTP. Fileserver (http. Dir ("/tmp/static/"))) HTTP. Listenandserve (": 8080", nil)}
Extract the Easyui front-end framework into the/tmp/static directory:
Executed under the Gopath
Go run Httpserver.go--path=/tmp/static