-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 1002 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"log"
"os"
// Blank-import the function package so the init() runs
// _ "example.com/gcf/v2"
"github.com/GoogleCloudPlatform/functions-framework-go/funcframework"
"github.com/joho/godotenv"
)
func main() {
// Load environment variables from .env file
godotenv.Load(".env")
// Use PORT environment variable, or default to 8080.
port := "8080"
if envPort := os.Getenv("PORT"); envPort != "" {
port = envPort
}
// By default, listen on all interfaces. If testing locally, run with
// LOCAL_ONLY=true to avoid triggering firewall warnings and
// exposing the server outside of your own machine.
// hostname := ""
// if localOnly := os.Getenv("LOCAL_ONLY"); localOnly == "true" {
// hostname = "127.0.0.1"
// }
hostname := "127.0.0.1"
//fmt.Fprintln(log, "OK")
log.Printf("Listening on http://%s:%s\n", hostname, port)
if err := funcframework.StartHostPort(hostname, port); err != nil {
log.Fatalf("funcframework.StartHostPort: %v\n", err)
}
}