(filepath string, v interface{}, opts Options)
| 75 | } |
| 76 | |
| 77 | func Load(filepath string, v interface{}, opts Options) (checksum *cos.Cksum, err error) { |
| 78 | var file *os.File |
| 79 | file, err = os.Open(filepath) |
| 80 | if err != nil { |
| 81 | return |
| 82 | } |
| 83 | checksum, err = Decode(file, v, opts, filepath) |
| 84 | if err == nil { |
| 85 | return |
| 86 | } |
| 87 | if errors.Is(err, &cos.ErrBadCksum{}) { |
| 88 | if errRm := os.Remove(filepath); errRm == nil { |
| 89 | if flag.Parsed() { |
| 90 | glog.Errorf("bad checksum: removing %s", filepath) |
| 91 | } |
| 92 | } else if flag.Parsed() { |
| 93 | glog.Errorf("bad checksum: failed to remove %s: %v", filepath, errRm) |
| 94 | } |
| 95 | } |
| 96 | return |
| 97 | } |
no test coverage detected