mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use make instead of new
This commit is contained in:
parent
7b1ec9ff30
commit
c4ebf870c8
1 changed files with 4 additions and 6 deletions
10
image.go
10
image.go
|
@ -267,13 +267,13 @@ func (img *Image) Checksum() (string, error) {
|
|||
}
|
||||
|
||||
checksumDictPth := path.Join(root, "..", "..", "checksums")
|
||||
checksums := new(map[string]string)
|
||||
checksums := make(map[string]string)
|
||||
|
||||
if checksumDict, err := ioutil.ReadFile(checksumDictPth); err == nil {
|
||||
if err := json.Unmarshal(checksumDict, checksums); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if checksum, ok := (*checksums)[img.Id]; ok {
|
||||
if checksum, ok := checksums[img.Id]; ok {
|
||||
return checksum, nil
|
||||
}
|
||||
}
|
||||
|
@ -304,10 +304,8 @@ func (img *Image) Checksum() (string, error) {
|
|||
}
|
||||
|
||||
hash := "sha256:" + hex.EncodeToString(h.Sum(nil))
|
||||
if *checksums == nil {
|
||||
*checksums = map[string]string{}
|
||||
}
|
||||
(*checksums)[img.Id] = hash
|
||||
checksums[img.Id] = hash
|
||||
|
||||
checksumJson, err := json.Marshal(checksums)
|
||||
if err != nil {
|
||||
return hash, err
|
||||
|
|
Loading…
Add table
Reference in a new issue