Skip to content

Commit fae42c4

Browse files
committed
feat: add environ
1 parent 9b0bf82 commit fae42c4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

environ.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package gcpen
2+
3+
import (
4+
"os"
5+
)
6+
7+
var (
8+
// ProjectID - Google Cloud Platform Project ID
9+
ProjectID = getProjectID()
10+
// ServiceName - Google App Engine service name
11+
ServiceName = os.Getenv(EnvKeyServiceName)
12+
// ServiceVersion - Google App Engine service version
13+
ServiceVersion = os.Getenv(EnvKeyServiceVersion)
14+
)
15+
16+
func getProjectID() string {
17+
id, ok := os.LookupEnv(EnvKeyProjectID)
18+
if ok {
19+
return id
20+
}
21+
22+
id, ok = os.LookupEnv(EnvKeyGoogleCloudProject)
23+
if ok {
24+
return id
25+
}
26+
27+
return ""
28+
}
29+
30+
// Reload - Reload environment variables.
31+
func Reload() {
32+
ProjectID = getProjectID()
33+
ServiceName = os.Getenv(EnvKeyServiceName)
34+
ServiceVersion = os.Getenv(EnvKeyServiceVersion)
35+
}

0 commit comments

Comments
 (0)