Remove unused ports

This commit is contained in:
Bel LaPointe
2018-10-09 09:07:48 -06:00
parent 798d451103
commit e4785e6a05
4 changed files with 13 additions and 19 deletions

View File

@@ -2,37 +2,34 @@ package config
import (
"flag"
"fmt"
"os"
"strings"
)
const cdbpath = "DBPath"
const port = "port"
const mport = "mport"
const fport = "fport"
type Config struct {
DBPath string
Port string
MonitorPort string
FetchPort string
DBPath string
Port string
}
func New() *Config {
lookups := make(map[string]*string)
add(cdbpath, "./db", lookups)
add(port, ":9101", lookups)
add(mport, ":9102", lookups)
add(fport, ":9103", lookups)
flag.Parse()
return &Config{
DBPath: *lookups[cdbpath],
Port: *lookups[port],
MonitorPort: *lookups[mport],
FetchPort: *lookups[fport],
DBPath: *lookups[cdbpath],
Port: *lookups[port],
}
}
func (c *Config) String() string {
return fmt.Sprintf("Port:%q", c.Port)
}
func add(key string, value string, lookups map[string]*string) {
env := os.Getenv(strings.ToUpper(key))
if env != "" {