我正在嘗試通過 Go 函數測試 URL。在我們的環境中,我們為每個環境設置了主機名,如下https://www/examplesite20193.domain.org是我所擁有的一個簡單示例:package mainimport ( "fmt" "net/http" "log")func main() { versionMaj := "2019" versionMin := "3" endpoint := versionMaj+versionMin resp, err:= http.Get("https://www.examplesite%s.domain.org", endpoint) if err != nil { log.Fatal(err) } fmt.Println("HTTP Response Status:", resp.StatusCode, http.StatusText(resp.StatusCode))}當我對此進行測試時,它在說明too many arguments in call to http.Get have (string, string) want (string). 有沒有辦法傳入一個參數,比如我指定的端點?
1 回答

米琪卡哇伊
TA貢獻1998條經驗 獲得超6個贊
可能你正在尋找這樣的東西:
resp, err:= http.Get(fmt.Sprintf("https://www.examplesite%s.domain.org", endpoint))
- 1 回答
- 0 關注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消