helpers.go 587 B

1234567891011121314151617181920212223242526
  1. package lib
  2. import (
  3. "log"
  4. "math/rand"
  5. )
  6. const Version string = "1.0"
  7. const Website string = "https://www.bananas-playground.net/projekt/scientia/"
  8. // ErrorCheck if error then display it with an addition message
  9. func ErrorCheck(e error, msg string) {
  10. if e != nil {
  11. log.Fatal(msg, " ; Message: ", e)
  12. }
  13. }
  14. // RandStringBytes creates just a random string
  15. func RandStringBytes(n int) string {
  16. var letters = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_"
  17. b := make([]byte, n)
  18. for i := range b {
  19. b[i] = letters[rand.Intn(len(letters))]
  20. }
  21. return string(b)
  22. }