Skip to content

Commit

Permalink
fix(cli): Fix some segmentation validation defers
Browse files Browse the repository at this point in the history
  • Loading branch information
etu committed Jun 23, 2024
1 parent 8a3a8e6 commit 6832c05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ func (cli *Cli) List(format string) {

// Do request to running instance of program
res, err := http.Get(requestUrl)
defer res.Body.Close()

if err != nil {
log.Printf("Failed to connect to running instance of program: %s\n", err)
os.Exit(1)
}

defer res.Body.Close()

// Validate status code
if res.StatusCode != http.StatusOK {
log.Printf("Unexpected status code when fetching active config: %d\n", res.StatusCode)
Expand All @@ -53,13 +54,14 @@ func (cli *Cli) List(format string) {

// Get the state
res, err = http.Get(requestUrl)
defer res.Body.Close()

if err != nil {
log.Printf("Failed to connect to running instance of program: %s\n", err)
os.Exit(1)
}

defer res.Body.Close()

// Validate status code
if res.StatusCode != http.StatusOK {
log.Printf("Unexpected status code when fetching active config: %d\n", res.StatusCode)
Expand Down

0 comments on commit 6832c05

Please sign in to comment.