Golang implementation of the Reliable UDP transport, revised from an original documented mostly in chinese.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.go 381B

12345678910111213141516171819202122232425262728293031
  1. package rudp
  2. import (
  3. "fmt"
  4. "log"
  5. )
  6. func dbg(format string, v ...interface{}) {
  7. if debug {
  8. log.Printf(format, v...)
  9. }
  10. }
  11. func checkErr(err error) {
  12. if err != nil {
  13. log.Printf("%v", err)
  14. }
  15. }
  16. func bitShow(n int) string {
  17. var ext string = "b"
  18. if n >= 1024 {
  19. n /= 1024
  20. ext = "Kb"
  21. }
  22. if n >= 1024 {
  23. n /= 1024
  24. ext = "Mb"
  25. }
  26. return fmt.Sprintf("%v %v", n, ext)
  27. }