diff --git a/go.mod b/go.mod index fa70624..9e3cdba 100644 --- a/go.mod +++ b/go.mod @@ -9,5 +9,6 @@ require ( github.com/dustin/go-jsonpointer v0.0.0-20160814072949-ba0abeacc3dc // indirect github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 // indirect + github.com/joho/godotenv v1.3.0 // indirect golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect ) diff --git a/go.sum b/go.sum index e64ddde..13ce5ab 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad h1:Qk76DOWdOp+GlyDKB github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad/go.mod h1:mPKfmRa823oBIgl2r20LeMSpTAteW5j7FLkc0vjmzyQ= github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 h1:GOfMz6cRgTJ9jWV0qAezv642OhPnKEG7gtUjJSdStHE= github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17/go.mod h1:HfkOCN6fkKKaPSAeNq/er3xObxTW4VLeY6UUK895gLQ= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index 3fc91f2..c75f914 100644 --- a/main.go +++ b/main.go @@ -13,21 +13,31 @@ import ( "time" "github.com/ChimeraCoder/anaconda" + "github.com/joho/godotenv" ) var ( api *anaconda.TwitterApi - port = os.Getenv("PORT") - tweetDateLayout = "Mon Jan 2 15:04:05 -0700 2006" - accessToken = os.Getenv("ACCESS_TOKEN") - accessTokenSecret = os.Getenv("ACCESS_TOKEN_SECRET") - consumerKey = os.Getenv("CONSUMER_KEY") - consumerSecret = os.Getenv("CONSUMER_SECRET") + port string + accessToken string + accessTokenSecret string + consumerKey string + consumerSecret string ) +func init() { + godotenv.Load(os.Getenv("DOTENV_DIR") + ".env") + + port = os.Getenv("PORT") + accessToken = os.Getenv("ACCESS_TOKEN") + accessTokenSecret = os.Getenv("ACCESS_TOKEN_SECRET") + consumerKey = os.Getenv("CONSUMER_KEY") + consumerSecret = os.Getenv("CONSUMER_SECRET") +} + func main() { if accessToken == "" || accessTokenSecret == "" || consumerKey == "" || consumerSecret == "" { panic("Missing Twitter credentials")