util.go 850 B

12345678910111213141516171819202122232425262728
  1. // Discordgo - Discord bindings for Go
  2. // Available at https://github.com/bwmarrin/discordgo
  3. // Copyright 2015 Bruce Marriner <bruce@sqls.net>. All rights reserved.
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file.
  6. // This file contains utility functions for the discordgo package. These
  7. // functions are not exported and are likely to change substantially in
  8. // the future to match specific needs of the discordgo package itself.
  9. package discordgo
  10. import (
  11. "bytes"
  12. "encoding/json"
  13. "fmt"
  14. )
  15. // printJSON is a helper function to display JSON data in a easy to read format.
  16. func printJSON(body []byte) {
  17. var prettyJSON bytes.Buffer
  18. error := json.Indent(&prettyJSON, body, "", "\t")
  19. if error != nil {
  20. fmt.Print("JSON parse error: ", error)
  21. }
  22. fmt.Println(string(prettyJSON.Bytes()))
  23. }