亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang 錯誤:未定義:http.NewSingleHostReverseProxy

Golang 錯誤:未定義:http.NewSingleHostReverseProxy

Go
catspeake 2021-07-01 10:00:42
我嘗試使用 Golang 構建一個簡單的程序,這里是:package mainimport (        "net/http"        "net/http/httputil"        "log")func main(){        proxy := http.NewSingleHostReverseProxy( &http.URL{Scheme:"http",Host:"www.google.com",Path:"/"})        err := http.ListenAndServe(":8080", proxy)        if err != nil {                log.Fatal("ListenAndServe: ", err.String())        }}建造:go build myprogram.go輸出:command-line-arguments./myprogram.go:5: imported and not used: "net/http/httputil"./myprogram.go:11: undefined: http.NewSingleHostReverseProxy./myprogram.go:11: undefined: http.URL./myprogram.go:15: err.String undefined (type error has no field or method String)我注意到 http.NewSingleHostReverseProxy 在“net/http/httputil”包中,為什么我會看到這樣的錯誤?也許我需要一個特定的命令來正確構建它?編輯 后記,這是新的工作代碼:package mainimport (        "net/http"        "net/http/httputil"        "net/url"        "log")func main(){        proxy := httputil.NewSingleHostReverseProxy( &url.URL{Scheme:"http",Host:"www.google.com",Path:"/"})        err := http.ListenAndServe(":8080", proxy)        if err != nil {                log.Fatal("ListenAndServe: ", err)        }}
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 331 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號