Skip to content

Commit

Permalink
cmd/lifectl: small cleanup for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Nov 13, 2023
1 parent 5236ac2 commit 9bb65c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
12 changes: 6 additions & 6 deletions cmd/lifectl/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func runMultiverse() {

func getUniverseList() (string, error) {
pth, _ := url.JoinPath(host, "multiverse")
resp, err := http.Get(pth)
r, err := http.Get(pth)
if err != nil {
return "", err
}
defer resp.Body.Close()
defer r.Body.Close()

body, err := io.ReadAll(resp.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -102,13 +102,13 @@ func tickUniverse(id string) (string, error) {

func getUniverse(id string) (string, error) {
pth, _ := url.JoinPath(host, "universe", id)
resp, err := http.Get(pth)
r, err := http.Get(pth)
if err != nil {
return "", err
}
defer resp.Body.Close()
defer r.Body.Close()

body, err := io.ReadAll(resp.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
return "", err
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/lifectl/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"io"
"net/http"
"net/url"
Expand All @@ -10,13 +11,17 @@ import (
func startMultiverse(size int) (string, error) {
pth, _ := url.JoinPath(host, "multiverse")
pth += "?n=" + strconv.Itoa(size)
resp, err := http.Post(pth, "", nil)
r, err := http.Post(pth, "", nil)
if err != nil {
return "", err
}
defer resp.Body.Close()
defer r.Body.Close()

body, err := io.ReadAll(resp.Body)
if r.StatusCode != http.StatusOK {
return "", errors.New("failed to start multiverse")
}

body, err := io.ReadAll(r.Body)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lifectl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func stopMultiverse() (string, error) {
defer r.Body.Close()

if r.StatusCode != http.StatusOK {
return "", errors.New("failed to delete multiverse")
return "", errors.New("failed to stop multiverse")
}

body, err := io.ReadAll(r.Body)
Expand Down

0 comments on commit 9bb65c5

Please sign in to comment.