env.go 463 B

12345678910111213141516171819202122232425262728293031
  1. package martini
  2. import (
  3. "os"
  4. )
  5. // Envs
  6. const (
  7. Dev string = "development"
  8. Prod string = "production"
  9. Test string = "test"
  10. )
  11. // Env is the environment that Martini is executing in. The MARTINI_ENV is read on initialization to set this variable.
  12. var Env = Dev
  13. var Root string
  14. func setENV(e string) {
  15. if len(e) > 0 {
  16. Env = e
  17. }
  18. }
  19. func init() {
  20. setENV(os.Getenv("MARTINI_ENV"))
  21. var err error
  22. Root, err = os.Getwd()
  23. if err != nil {
  24. panic(err)
  25. }
  26. }