1
,我有以下結構爲什麼外地部分沒有得到嵌入
package router
import (
"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
}
而且我想在像另一個結構嵌入:
package router
import (
"net/http"
"townspeech/types"
"townspeech/components/session"
"townspeech/controllers/base"
)
type authHandler struct {
sidHandler
handler authFuncHandler
auth *session.Auth
}
,功能,使用該authHandler結構:
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 literal
FAIL app/test/account/validation [build failed]
正如你所看到的,這兩個結構體在同一個包中,字段部分不應該顯示爲私有的。
我在做什麼錯?
例如:https://play.golang.org/p/uwvxaaCo4V –