28 lines
480 B
Go
28 lines
480 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"gopkg.in/yaml.v2"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
ScriptBinaryPath string `yaml:"script_binary_path"`
|
||
|
WebhookScriptPath string `yaml:"webhook_script_path"`
|
||
|
FileToWatchPath string `yaml:"file_to_watch_path"`
|
||
|
}
|
||
|
|
||
|
func LoadConfig(path string) (*Config, error) {
|
||
|
data, err := os.ReadFile(path)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
var config Config
|
||
|
if err := yaml.Unmarshal(data, &config); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &config, nil
|
||
|
}
|