-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.go
More file actions
47 lines (37 loc) · 908 Bytes
/
config.go
File metadata and controls
47 lines (37 loc) · 908 Bytes
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
//go:build goverage
package goverage
import (
"os"
"time"
)
const (
defaultPort = "7777"
coverageEndpoint = "/v1/cover/profile"
portEnvVar = "COVERAGE_HTTP_PORT"
coverDirEnvVar = "GOCOVERDIR"
temporaryCoverageFile = "/tmp/coverage.out"
coverageFileMode = 0o755
requestTimeout = 60 * time.Second
readTimeout = 15 * time.Second
readHeaderTimeout = 15 * time.Second
writeTimeout = 30 * time.Second
idleTimeout = 60 * time.Second
contentTypeTextPlain = "text/plain; charset=utf-8"
modePrefix = "mode:"
)
type Config struct {
Port string
CoverDir string
}
func NewConfig() *Config {
return &Config{
Port: getEnvOrDefault(portEnvVar, defaultPort),
CoverDir: os.Getenv(coverDirEnvVar),
}
}
func getEnvOrDefault(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}