paste-abroad/internel/config/config.go

29 lines
595 B
Go
Raw Permalink Normal View History

package config
import (
"github.com/BurntSushi/toml"
"os"
)
type Config struct {
DefaultLifetime int64 `toml:"lifetime"`
IdLength int `toml:"id_length"`
Database string `toml:"database"`
DBString string `toml:"db_string"`
MaxPasteSize int64 `toml:"max_paste_size"`
}
func Load(path string) (*Config, error) {
buffer, err := os.ReadFile(path)
if err != nil {
return nil, err
}
config_content := string(buffer)
var c Config
toml.Decode(config_content, &c)
return &c, nil
}