Added config with version
This commit is contained in:
parent
9b65b01ccb
commit
7281837015
0
cmd/twister/config.toml
Normal file
0
cmd/twister/config.toml
Normal file
@ -1,4 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
|
||||
"git.supernets.org/vortex/twister/config"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed config.toml
|
||||
content []byte
|
||||
|
||||
version = "0.1.0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
conf := config.Parse(content)
|
||||
conf.Version = version
|
||||
fmt.Println(conf)
|
||||
}
|
||||
|
6
config/config.go
Normal file
6
config/config.go
Normal file
@ -0,0 +1,6 @@
|
||||
package config
|
||||
|
||||
// Config is a configuration
|
||||
type Config struct {
|
||||
Version string
|
||||
}
|
15
config/parse.go
Normal file
15
config/parse.go
Normal file
@ -0,0 +1,15 @@
|
||||
package config
|
||||
|
||||
import "github.com/BurntSushi/toml"
|
||||
|
||||
// Parse the config
|
||||
func Parse(content []byte) *Config {
|
||||
var cfg *Config
|
||||
|
||||
err := toml.Unmarshal(content, &cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
||||
module git.supernets.org/vortex/twister
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require github.com/BurntSushi/toml v1.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user