Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit dd16766

Browse files
author
Matthieu Nottale
committed
extract: Factor noop func.
Signed-off-by: Matthieu Nottale <[email protected]>
1 parent c2dd2c8 commit dd16766

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packager/extract.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
"github.com/docker/lunchbox/utils"
1010
)
1111

12+
var (
13+
noop = func() {}
14+
)
15+
1216
// Extract extracts the app content if argument is an archive, or does nothing if a dir.
1317
// It returns effective app name, and cleanup function
1418
func Extract(appname string) (string, func(), error) {
@@ -20,20 +24,20 @@ func Extract(appname string) (string, func(), error) {
2024
s, err = os.Stat(appname)
2125
}
2226
if err != nil {
23-
return "", func() {}, err
27+
return "", noop, err
2428
}
2529
if s.IsDir() {
2630
// directory: already decompressed
27-
return appname, func() {}, nil
31+
return appname, noop, nil
2832
}
2933
// not a dir: probably a tarball package, extract that in a temp dir
3034
tempDir, err := ioutil.TempDir("", "dockerapp")
3135
if err != nil {
32-
return "", func() {}, err
36+
return "", noop, err
3337
}
3438
err = extract(appname, tempDir)
3539
if err != nil {
36-
return "", func() {}, err
40+
return "", noop, err
3741
}
3842
return tempDir, func() { os.RemoveAll(tempDir) }, nil
3943
}

0 commit comments

Comments
 (0)