-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Refactor project structure
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.env | ||
*.env | ||
config.production.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
app: | ||
name: 'Go GQL' | ||
version: '1.0.0' | ||
is_use_fake_data: true | ||
|
||
http: | ||
port: '8080' | ||
|
||
database: | ||
pool_max: 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/go-graphql/pkg/logger" | ||
"github.com/ilyakaznacheev/cleanenv" | ||
) | ||
|
||
type ( | ||
Config struct { | ||
App `yaml:"app"` | ||
HTTP `yaml:"http"` | ||
Database `yaml:"database"` | ||
} | ||
|
||
App struct { | ||
Name string `env-required:"true" yaml:"name"` | ||
Version string `env-required:"true" yaml:"version"` | ||
IsUseFakeData bool `env-required:"true" yaml:"is_use_fake_data"` | ||
} | ||
|
||
// HTTP -. | ||
HTTP struct { | ||
Port string `env-required:"true" yaml:"port"` | ||
} | ||
|
||
Database struct { | ||
PoolMax int `env-required:"true" yaml:"pool_max"` | ||
} | ||
) | ||
|
||
// NewConfig returns app config. | ||
func NewConfig() *Config { | ||
cfg := &Config{} | ||
|
||
err := cleanenv.ReadConfig("./config/config-development.yml", cfg) // Change this base on your env | ||
if err != nil { | ||
logger.Log.Fatalln(err) | ||
} | ||
|
||
err = cleanenv.ReadEnv(cfg) | ||
if err != nil { | ||
logger.Log.Fatalln(err) | ||
} | ||
|
||
return cfg | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.