Skip to content

Commit

Permalink
moved format func to format.go file
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticrabbit committed Nov 17, 2021
1 parent b2e14a2 commit 0d667ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 15 additions & 0 deletions internal/format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package internal

import (
"bytes"
"encoding/json"
"log"
)

func FormatJSON(jsonresp []byte) string {
var formattedJSON bytes.Buffer
if err := json.Indent(&formattedJSON, jsonresp, "", " "); err != nil {
log.Fatalln(err)
}
return formattedJSON.String()
}
10 changes: 0 additions & 10 deletions internal/requester.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package internal

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
Expand Down Expand Up @@ -44,14 +42,6 @@ func getJSON(apiPath string) []byte {
return resp_body
}

func FormatJSON(jsonresp []byte) string {
var formattedJSON bytes.Buffer
if err := json.Indent(&formattedJSON, jsonresp, "", " "); err != nil {
log.Fatalln(err)
}
return formattedJSON.String()
}

func Request(r Requester) {
fmt.Println(FormatJSON(r.GetJSON(r.BuildPath())))
}

0 comments on commit 0d667ea

Please sign in to comment.