Пример #1
0
func (s *S) TestStrings(c *C) {
	c.Assert(func() { env.String("DOESNT_EXIST") }, Panics, errors.New("env: Environment variable DOESNT_EXIST doesn't exist"))

	os.Setenv("test", "gocheck")
	test := map[string]string{
		env.String("test"):                                               "gocheck",
		env.StringDefault("foobar", "fizzbin"):                           "fizzbin",
		env.StringDefaultF("foobar", func() string { return "fizzbot" }): "fizzbot",
	}

	for obtained, expected := range test {
		c.Assert(obtained, Equals, expected)
	}
}
Пример #2
0
	SubmitError    = "submit.error"
	SubmitEmail    = "submit.email"
	PostmarkBounce = "postmark.bounce"

	ContentType           = "Content-Type"
	Location              = "Location"
	ContentTypeHTML       = "text/html; charset=utf-8"
	ContentTypePlain      = "text/plain; charset=utf-8"
	ContentTypeJavascript = "application/javascript; charset=utf-8"
	ContentTypeJSON       = "application/json; charset=utf-8"
)

var (
	doneRegex     = regexp.MustCompile("(?i:done|failed|limited|invalid|error|sorry)")
	port          = env.IntDefault("PORT", 8080)
	canonicalHost = env.StringDefaultF("CANONICAL_HOST", func() string { return fmt.Sprintf("tinderizer.dev:%d", port) })
	logger        = log.New(os.Stdout, "[server] ", env.IntDefault("LOG_FLAGS", log.LstdFlags|log.Lmicroseconds))
	templates     = template.Must(template.ParseGlob("views/*.tmpl"))
	app           *tinderizer.App
)

type JSON map[string]interface{}

func init() {
	redis := env.StringDefault("REDISCLOUD_URL", env.StringDefault("REDIS_PORT", ""))
	if redis != "" {
		cache.SetupRedis(redis, env.StringDefault("REDIS_OPTIONS", "timeout=15s&maxidle=1"))
	}

	rdbToken := env.String("READABILITY_TOKEN")
	pmToken := env.String("POSTMARK_TOKEN")
Пример #3
0
package config

import (
	"fmt"
	"github.com/darkhelmet/env"
	"log"
)

var (
	Port            = env.IntDefault("PORT", 5000)
	CanonicalHost   = env.StringDefaultF("CANONICAL_HOST", func() string { return fmt.Sprintf("localhost:%d", Port) })
	AssetHost       = env.StringDefaultF("ASSET_HOST", func() string { return fmt.Sprintf("http://%s", CanonicalHost) })
	LogFlags        = env.IntDefault("LOG_FLAGS", log.LstdFlags|log.Lmicroseconds)
	SiteTitle       = "Verbose Logging"
	SiteDescription = "software development with some really amazing hair"
	SiteContact     = "*****@*****.**"
	SiteAuthor      = "Daniel Huckstep"
)