add project first skeleton
This commit is contained in:
6
internal/app/app.go
Normal file
6
internal/app/app.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package app
|
||||
|
||||
|
||||
type App struct {
|
||||
// Application state and configurations can be added here
|
||||
}
|
||||
9
internal/app/errors.go
Normal file
9
internal/app/errors.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNilPointerWarn = errors.New("nil pointer dereference warning")
|
||||
)
|
||||
26
internal/config/config.go
Normal file
26
internal/config/config.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/akyaiy/GSfass/core/config"
|
||||
)
|
||||
|
||||
type ServerConfig struct {
|
||||
Port int `mapstructure:"port"`
|
||||
Addr string `mapstructure:"address"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig `mapstructure:"server"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
var cfg Config
|
||||
err := config.Read().Config().FilePath(path).SetBy(&cfg).SetDefaults(map[string]any{
|
||||
"server.port": 8080,
|
||||
"server.address": "127.0.0.0",
|
||||
}).End()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user