From 462d0a77def48c79aefc2f2dfdae37ee5affce26 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Thu, 23 Jan 2020 19:41:57 -0500 Subject: add support for config files 2.2.0 will not be released until libuconf is stabilized --- go.mod | 1 + go.sum | 7 +++++++ main.go | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3b32cce..39af24a 100644 --- a/go.mod +++ b/go.mod @@ -12,4 +12,5 @@ require ( github.com/valyala/fasthttp v1.7.0 github.com/valyala/quicktemplate v1.4.1 golang.org/x/text v0.3.2 // indirect + toast.cafe/x/libuconf v0.0.0-20200124004008-45952396b95f ) diff --git a/go.sum b/go.sum index 2a44113..9dead7c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fasthttp/router v0.5.2 h1:xdmx8uYc9IFDtlbG2/FhE1Gyowv7/sqMgMonRjoW0Yo= github.com/fasthttp/router v0.5.2/go.mod h1:Y5JAeRTSPwSLoUgH4x75UnT1j1IcAgVshMDMMrnNmKQ= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -27,6 +29,8 @@ github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= +github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/savsgio/gotils v0.0.0-20190925070755-524bc4f47500 h1:9Pi10H7E8E79/x2HSe1FmMGd7BJ1WAqDKzwjpv+ojFg= @@ -72,3 +76,6 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +toast.cafe/x/libuconf v0.0.0-20200124004008-45952396b95f h1:opJptxVMyKft6jN2+LOznwyZoxTVyEj7dD1n/ucrbgg= +toast.cafe/x/libuconf v0.0.0-20200124004008-45952396b95f/go.mod h1:BzekZryrvuHy7+yOweg1f6yC8//HMKG/wMsRbXBXeog= diff --git a/main.go b/main.go index 0cdf9c4..3e983ab 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "flag" "fmt" "os" @@ -9,6 +8,7 @@ import ( "github.com/valyala/fasthttp" "toast.cafe/x/brpaste/v2/http" "toast.cafe/x/brpaste/v2/storage" + "toast.cafe/x/libuconf" ) var s settings @@ -21,6 +21,7 @@ type settings struct { func main() { // ---- Flags + flag := libuconf.DefaultSet flag.StringVar(&s.Bind, "bind", ":8080", "address to bind to") flag.StringVar(&s.Redis, "redis", "redis://localhost:6379", "redis connection string") flag.StringVar(&s.Storage, "storage", "redis", "type of storage to use") -- cgit v1.2.3