-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.go
61 lines (50 loc) · 1.04 KB
/
default.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (c) 2019. Octofox.io
*/
package foundation
import (
"fmt"
"os"
"time"
)
const (
// Generate TLS certification for GRPC
// ```
// docker run -itv `pwd`:/opt/certstrap/out biscarch/certstrap init --common-name "*" (For wildcard certificate)
// mv *.crt server_test.crt
// mv *.key server_test.key
// ```
OCTOFOX_FOUNDATION_GRPC_CERT = "OCTOFOX_FOUNDATION_GRPC_CERT"
OCTOFOX_FOUNDATION_GRPC_KEY = "OCTOFOX_FOUNDATION_GRPC_KEY"
GRPC_METADATA_AUTHORIZATION_KEY = "Authorization"
GRPC_METADATA_REQUEST_ID_KEY = "RequestID"
)
func String(v string) *string {
return &v
}
func Bool(v bool) *bool {
return &v
}
func Int(v int) *int {
return &v
}
func Int64(v int64) *int64 {
return &v
}
func Time(t time.Time) *time.Time {
return &t
}
func EnvStringOrPanic(key string) string {
value := os.Getenv(key)
if value == "" {
panic(fmt.Sprintf("Env %s not provide", key))
}
return value
}
func EnvString(key, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}