go 语言跳转地址


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

猜你喜欢

转载自blog.csdn.net/qq_37838223/article/details/80493114