Skip to content

Commit 297d5a5

Browse files
committed
Fix file errors in utilities.
1 parent c3d53d0 commit 297d5a5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

cmd/go-bsdiff/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313

1414
argOld = cli.Arg("old", "The old file.").Required().ExistingFile()
1515
argNew = cli.Arg("new", "The new file.").Required().ExistingFile()
16-
argPatch = cli.Arg("patch", "Where to output the patch file.").Required().File()
16+
argPatch = cli.Arg("patch", "Where to output the patch file.").Required().String()
1717
)
1818

1919
func must(err error) {
@@ -27,7 +27,8 @@ func must(err error) {
2727
func main() {
2828
kingpin.MustParse(cli.Parse(os.Args[1:]))
2929

30-
patchFile := *argPatch
30+
patchFile, err := os.Create(*argPatch)
31+
must(err)
3132
defer patchFile.Close()
3233

3334
oldFile, err := os.Open(*argOld)

cmd/go-bspatch/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var (
1212
cli = kingpin.New("go-bspatch", "Applies binary patches generated using the bsdiff algorithm.")
1313

1414
argOld = cli.Arg("old", "The old file.").Required().ExistingFile()
15-
argNew = cli.Arg("new", "Where the new file will be written to.").Required().File()
15+
argNew = cli.Arg("new", "Where the new file will be written to.").Required().String()
1616
argPatch = cli.Arg("patch", "The patch file.").Required().ExistingFile()
1717
)
1818

@@ -27,13 +27,14 @@ func must(err error) {
2727
func main() {
2828
kingpin.MustParse(cli.Parse(os.Args[1:]))
2929

30-
newFile := *argNew
31-
defer newFile.Close()
32-
3330
oldFile, err := os.Open(*argOld)
3431
must(err)
3532
defer oldFile.Close()
3633

34+
newFile, err := os.Create(*argNew)
35+
must(err)
36+
defer newFile.Close()
37+
3738
patchFile, err := os.Open(*argPatch)
3839
must(err)
3940
defer patchFile.Close()

0 commit comments

Comments
 (0)