第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 Go 向本地主機(jī)服務(wù)器發(fā)出 GET http 請(qǐng)求時(shí)出現(xiàn)空響應(yīng)

使用 Go 向本地主機(jī)服務(wù)器發(fā)出 GET http 請(qǐng)求時(shí)出現(xiàn)空響應(yīng)

Go
千萬(wàn)里不及你 2021-08-30 15:16:45
我的本地主機(jī)服務(wù)器正在運(yùn)行,它只是 docker 中的容器進(jìn)程。我正在嘗試實(shí)現(xiàn) Go CLIENT 來(lái)構(gòu)建用于創(chuàng)建、列出、更新、刪除功能的 REST api。當(dāng)我嘗試點(diǎn)擊 URL 時(shí),程序成功退出但給我一個(gè)空響應(yīng)。我進(jìn)一步觀察到,響應(yīng)類型被“分塊”,內(nèi)容長(zhǎng)度為 -1。我是 Go 的新手,并試圖找出可能的原因是什么,或者任何人都可以為這個(gè)問(wèn)題提供解決方案。這是我的代碼 - { package mainimport (    "encoding/json"    "fmt"    "io/ioutil"    "net/http")type Payload struct {    Stuff Data}type Data struct {    Id              string    Links           Links_container    Actions         Actions_container    AccountID       string    AgentID         string    AllocationState string    Compute         string    Created         string}type Links_container map[string]stringtype Actions_container map[string]stringfunc main() {    url := "http://localhost:8080/v1/containers"    res, err := http.Get(url)    if err != nil {        fmt.Println(err)    }    defer res.Body.Close()    body, err := ioutil.ReadAll(res.Body)    if err != nil {        fmt.Println(err)    }    var p Payload    err = json.Unmarshal(body, &p)    if err != nil {        panic(err)    }    fmt.Println(p.Stuff.AccountID, "\n", p.Stuff.Actions, "\n",        p.Stuff.AgentID, "\n", p.Stuff.AllocationState, "\n", p.Stuff.Compute,        "\n", p.Stuff.Created, "\n", p.Stuff.Id, "\n", p.Stuff.Links)}}
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 355 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)