// gin.go // HandlerFunc defines the handler used by gin middleware as return value. type HandlerFunc func(*Context) // HandlersChain defines a HandlerFunc array. type HandlersChain []HandlerFunc // Last returns the last handler in the chain. ie. the last handler is the main one. func (c HandlersChain) Last() HandlerFunc {
// 注意这里未使用 && 而是用的分号 ; 将传统 for 循环中的相似语义给通用化了 if length := len(c); length > 0 { return c[length-1] } return nil }
[Gin] 传统 for 循环中的语义通用化,在 golang 中使用分号 ; 替代 && 流程控制
猜你喜欢
转载自www.cnblogs.com/farwish/p/12703925.html
今日推荐
周排行