Skip to content

zbum/mantyboot

Repository files navigation

manty-boot

Configuration

  • configuration module like spring-boot's ConfigurationProperties

Install

go get github.com/zbum/mantyboot/configuration

Usage

  • If you have file structure like below, It loads files order by (embedfs -> ./application-dev.yaml -> ./config/application-dev.yaml)
.
├── application-dev.yaml
├── config
│   └── application-dev.yaml
└── example
    ├── configuration_ex1.go
    └── embed
        └── application-dev.yaml
package main

import (
    "embed"
    "fmt"
    "github.com/zbum/mantyboot/configuration"
)

type ExampleConfiguration struct {
    ServerName string `yaml:"server-name"`
    ServerPort string `yaml:"server-port"`
}

//go:embed embed/application-dev.yaml
var devfs embed.FS

func main() {
    ex1Configuration, err := configuration.NewConfiguration[ExampleConfiguration](devfs, "dev")
    if err != nil {
        return
    }
    fmt.Println(ex1Configuration.GetConfiguration())
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages