update func comment (#981)

This commit is contained in:
田欧
2017-07-06 09:28:16 +08:00
committed by Bo-Yi Wu
parent 22ee916dfe
commit b985857899
6 changed files with 15 additions and 16 deletions
+5 -6
View File
@@ -69,7 +69,7 @@ func (msg *Error) MarshalJSON() ([]byte, error) {
return json.Marshal(msg.JSON())
}
// Implements the error interface
// Error implements the error interface
func (msg Error) Error() string {
return msg.Err.Error()
}
@@ -78,7 +78,7 @@ func (msg *Error) IsType(flags ErrorType) bool {
return (msg.Type & flags) > 0
}
// Returns a readonly copy filtered the byte.
// ByType returns a readonly copy filtered the byte.
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
if len(a) == 0 {
@@ -96,17 +96,16 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
return result
}
// Returns the last error in the slice. It returns nil if the array is empty.
// Last returns the last error in the slice. It returns nil if the array is empty.
// Shortcut for errors[len(errors)-1]
func (a errorMsgs) Last() *Error {
length := len(a)
if length > 0 {
if length := len(a); length > 0 {
return a[length-1]
}
return nil
}
// Returns an array will all the error messages.
// Errors returns an array will all the error messages.
// Example:
// c.Error(errors.New("first"))
// c.Error(errors.New("second"))