Skip to content

Commit

Permalink
cmd/preprofile: drop output directory check
Browse files Browse the repository at this point in the history
This check serves only to provide a more descriptive error if the output
directory doesn't exist. That isn't useless, but I don't see why this tool
specifically should do this when no other part of the toolchain does.

For golang#58102.

Change-Id: I01cf9db2cc1dad85c3afd8a6b008c53f26cb877a
Reviewed-on: https://go-review.googlesource.com/c/go/+/569336
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
prattmic authored and Mchnan committed Mar 28, 2024
1 parent c3ea99c commit 16041e3
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/cmd/preprofile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"internal/profile"
"log"
"os"
"path/filepath"
"strconv"
)

Expand Down Expand Up @@ -132,21 +131,11 @@ func preprocess(profileFile string, outputFile string, verbose bool) error {
if outputFile == "" {
fNodeMap = os.Stdout
} else {
dirPath := filepath.Dir(outputFile)
_, err := os.Stat(dirPath)
if err != nil {
return fmt.Errorf("directory does not exist: %s", dirPath)
}
base := filepath.Base(outputFile)
outputFile = filepath.Join(dirPath, base)

// write out NodeMap to a file
fNodeMap, err = os.Create(outputFile)
if err != nil {
return fmt.Errorf("Error creating output file: %w", err)
}

defer fNodeMap.Close() // Close the file when done writing
defer fNodeMap.Close()
}

w := bufio.NewWriter(fNodeMap)
Expand Down

0 comments on commit 16041e3

Please sign in to comment.