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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章