Можно использовать Indent
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
artist := "Madonna"
token := "5936fb55e90cdd9938f8e7086c783c40"
url := fmt.Sprintf(
"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=%s&api_key=%s&format=json", artist, token)
res, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
var pretty bytes.Buffer
err = json.Indent(&pretty, body, "", "\t")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v\n", string(pretty.Bytes()))
}