Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (23 sloc) 523 Bytes
package main /* import "s32x.com/ipdata" */
import (
"log"
"os"
"s32x.com/ipdata/service"
)
func main() {
service.Start(
getenv("PORT", "8080"),
getenv("ENV", "dev"),
)
}
// getenv attempts to retrieve and return a variable from the environment. If it
// fails it will either crash or failover to a passed default value
func getenv(key string, def ...string) string {
if v, ok := os.LookupEnv(key); ok {
return v
}
if len(def) == 0 {
log.Fatalf("%s not defined in environment", key)
}
return def[0]
}