App for fetching and uploading images to cloud bucket storage

This commit is contained in:
2022-12-10 15:27:24 +01:00
commit b56c3d1e29
18 changed files with 749 additions and 0 deletions

28
config/config.go Normal file
View File

@@ -0,0 +1,28 @@
// Package config handles environment variables.
package config
import (
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
log "github.com/sirupsen/logrus"
)
// Config contains environment variables.
type Config struct {
Hostname string `envconfig:"HOSTNAME"`
GCSBucket string `envconfig:"GCS_BUCKET" default:"p"`
Port string `envconfig:"PORT" default:"8000"`
}
// LoadConfig reads environment variables, populates and returns Config.
func LoadConfig() (*Config, error) {
if err := godotenv.Load(); err != nil {
log.Info("No .env file found")
}
var c Config
err := envconfig.Process("", &c)
return &c, err
}