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

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

如何讀取 Go 中的嵌入字段?

如何讀取 Go 中的嵌入字段?

Go
牛魔王的故事 2022-01-17 19:53:51
我設(shè)計(jì)了一個(gè)新的 Request 結(jié)構(gòu),但在某些情況下(http.Redirect),我需要獲取 origin http.Request。我的請(qǐng)求結(jié)構(gòu):type Request struct {    *http.Request}func (r *Request) IsGet() bool {    return strings.EqualFold("GET", r.Method)}主功能:    req := http.Request{        Method:"POST",    }    myReq := &Request{&req}    // How to get original request.    originalReq, ok := (interface{}(*myReq)).(http.Request);    if ok {        fmt.Printf("Method: %s\n", originalReq.Method)    } else {        fmt.Println("Failure")    }
查看完整描述

1 回答

?
江戶川亂折騰

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊

讓我們看看語(yǔ)言規(guī)范是怎么說(shuō)的:


非限定類型名稱充當(dāng)字段名稱。


// A struct with four anonymous fields of type T1, *T2, P.T3 and *P.T4

struct {

  T1        // field name is T1

  *T2       // field name is T2

  P.T3      // field name is T3

  *P.T4     // field name is T4

  x, y int  // field names are x and y

}

IE myReq.Request


查看完整回答
反對(duì) 回復(fù) 2022-01-17
  • 1 回答
  • 0 關(guān)注
  • 152 瀏覽
慕課專欄
更多

添加回答

舉報(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)