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

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

為什么沒有嵌入字段部分

為什么沒有嵌入字段部分

Go
SMILET 2021-09-27 21:23:45
我有以下結(jié)構(gòu)package routerimport (    "io"    "net/http"    "townspeech/components/i18n"    "townspeech/components/policy"    "townspeech/components/session"    "townspeech/controllers/base"    "townspeech/types")type sidHandler struct {    req     *http.Request    res     http.ResponseWriter    handler sidFuncHandler    section string    err     *types.ErrorJSON    sess    *session.Sid}我想嵌入另一個(gè)結(jié)構(gòu),如:package routerimport (    "net/http"    "townspeech/types"    "townspeech/components/session"    "townspeech/controllers/base")type authHandler struct {    sidHandler    handler authFuncHandler    auth    *session.Auth}以及使用 authHandler 結(jié)構(gòu)的函數(shù):func registerAuthHandler(handler authFuncHandler, section string) http.Handler {    return &authHandler{handler: handler, section: section}}編譯器抱怨:# app/router../../../router/funcs.go:9: unknown authHandler field 'section' in struct literalFAIL    app/test/account/validation [build failed]如您所見,這兩個(gè)結(jié)構(gòu)體在同一個(gè)包中,字段部分不應(yīng)顯示為私有。我究竟做錯(cuò)了什么?
查看完整描述

2 回答

?
動(dòng)漫人物

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

嵌入不適用于這樣的文字。


func registerAuthHandler(handler authFuncHandler, section string) http.Handler {

    return &authHandler{

        handler: handler,

        sidHandler: sidHandler{section: section},

    }

}


查看完整回答
反對 回復(fù) 2021-09-27
?
米脂

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

您不能在結(jié)構(gòu)文字中引用提升的字段。您必須創(chuàng)建嵌入類型,并通過類型名稱引用它。


&authHandler{

    sidHandler: sidHandler{section: "bar"},

    handler:    "foo",

}


查看完整回答
反對 回復(fù) 2021-09-27
  • 2 回答
  • 0 關(guān)注
  • 206 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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