package main import ( "log" "net/http" ) func addUser(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "https://blog.csdn.net/qq_37838223", http.StatusFound) } func main() { http.HandleFunc("/", addUser) err := http.ListenAndServe(":80", nil) if err != nil { log.Fatal("ListenAndServe: ", err.Error()) } }
最后 set GOOS=linux,在linux上运行,windows则不用
打包go文件: go build xxxx.go
有疑问加站长微信联系(非本文作者)