我有以下结构
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]
如您所见,这两个结构体在同一个包中,字段部分不应显示为私有。
我究竟做错了什么?
动漫人物
米脂
相关分类