github.com/golang/dep@v0.5.4/gps/error.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package gps
     6  
     7  import (
     8  	"bytes"
     9  	"fmt"
    10  )
    11  
    12  type errorSlice []error
    13  
    14  func (errs errorSlice) Error() string {
    15  	var buf bytes.Buffer
    16  	fmt.Fprintln(&buf)
    17  	for i, err := range errs {
    18  		fmt.Fprintf(&buf, "\t(%d) %s\n", i+1, err)
    19  	}
    20  	return buf.String()
    21  }
    22  
    23  func (errs errorSlice) Format(f fmt.State, c rune) {
    24  	fmt.Fprintln(f)
    25  	for i, err := range errs {
    26  		if ferr, ok := err.(fmt.Formatter); ok {
    27  			fmt.Fprintf(f, "\t(%d) ", i+1)
    28  			ferr.Format(f, c)
    29  			fmt.Fprint(f, "\n")
    30  		} else {
    31  			fmt.Fprintf(f, "\t(%d) %s\n", i+1, err)
    32  		}
    33  	}
    34  }