萧十郎
package mainimport ( "flag" "log" "net/http")func main() { port := flag.String("p", "8181", "port to serve on") directory := flag.String("d", "web", "the directory of static file to host") flag.Parse() http.Handle("/", http.FileServer(http.Dir(*directory))) log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) log.Fatal(http.ListenAndServe(":"+*port, nil))}只需将 web 文件夹复制到您的 go 应用程序即可。