mirror of https://github.com/shirou/gopsutil
[disk][host]: change to use type alias.
parent
4ac7e99c6a
commit
5473fd114d
@ -1,30 +0,0 @@
|
||||
package host
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Warnings struct {
|
||||
List []error
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
func (w *Warnings) Add(err error) {
|
||||
w.List = append(w.List, err)
|
||||
}
|
||||
|
||||
func (w *Warnings) Reference() error {
|
||||
if len(w.List) > 0 {
|
||||
return w
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Warnings) Error() string {
|
||||
if w.Verbose {
|
||||
str := ""
|
||||
for i, e := range w.List {
|
||||
str += fmt.Sprintf("\tError %d: %s\n", i, e.Error())
|
||||
}
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("Number of warnings: %v", len(w.List))
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package disk
|
||||
package common
|
||||
|
||||
import "fmt"
|
||||
|
Loading…
Reference in New Issue