github.com/hazelops/ize@v1.1.12-0.20230915191306-97d7c0e48f11/examples/ecs-apps-monorepo/apps/goblin/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "net/http" 6 "os" 7 ) 8 9 func main() { 10 11 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 12 VarEnv := getEnv("EXAMPLE_SECRET", "default-pass") 13 VarSecret := getEnv("EXAMPLE_API_KEY", "default-pass") 14 fmt.Fprintln(w, VarSecret, "Welcome to goblin! demo service👾") 15 fmt.Fprintln(w, VarEnv, "Welcome to goblin! demo service👾") 16 }) 17 println("Goblin demo service started on port 3000") 18 http.ListenAndServe(":3000", nil) 19 } 20 21 // getEnv get key environment variable if exist otherwise return defalutValue 22 func getEnv(key, defaultValue string) string { 23 value := os.Getenv(key) 24 if len(value) == 0 { 25 return defaultValue 26 } 27 return value 28 }