我写了 2 个函数v1GetSessionID和v1SessionIDforBind。
/*
* v1GetSessionID
*/
func v1GetSessionID(c *gin.Context,
app *firebase.App,
client *firestore.Client,
stripcallGetSession func() func(internalUserID string, customerID string) (sessionid string, err error)) (sessionid string, err error) {
defer erapse.ShowErapsedTIme(time.Now())
idToken := c.Param("idToken")
user, err := idToken2User(app, idToken)
if err != nil {return}
customerID, err := user.getCustomerID()
if err != nil {return}
sessionid, err = stripcallGetSession()(user.getInternalID(), customerID)
return
}
/*
* v1SessionIDforBind
*/
func v1SessionIDforBind(c *gin.Context, app *firebase.App, client *firestore.Client) {
defer erapse.ShowErapsedTIme(time.Now())
var requestBody JsonPurchaseBindSessionRequest
if err := c.ShouldBindJSON(&requestBody); err != nil {
okngErrorOut(c, err)
return
}
stripcallGetSession := func() func(internalUserID string, customerID string) (sessionid string, err error) {
return func(internalUserID string, customerID string)(sessionid string, err error){return stripeGetSessionIDforBind(requestBody, internalUserID, customerID)}
}
sessionid, err := v1GetSessionID(c, app, client, stripcallGetSession)()
if err != nil {
log.Println(err)
okngErrorOut(c, err)
} else {
c.JSON(http.StatusOK, gin.H{
"SessionID": sessionid,
})
}
}
在后一个函数的中间,我将前者称为如下;
sessionid, err := v1GetSessionID(c, app, client, stripcallGetSession)()
但是 go 编译器在单值上下文中将其指示为多值。
go run *.go
# command-line-arguments
./v1handler.go:332:34: multiple-value v1GetSessionID() in single-value context
v1GetSessionID 返回 sessionid 字符串的 2 个值,err 错误,我已通过sessionid,err收到它。那么为什么我有上面提到的错误呢?
go 版本为:go1.14.4 linux/arm。
饮歌长啸
相关分类