Andrey Ivanov 1974db73ab
All checks were successful
continuous-integration/drone/push Build is passing
initial_code (#1)
Reviewed-on: #1
2023-04-20 14:52:38 +00:00

27 lines
402 B
Go

package scenario
import (
"os"
"github.com/go-playground/validator/v10"
"gopkg.in/yaml.v2"
)
func Get(file string) (*Object, error) {
var obj Object
yamlFile, err := os.ReadFile(file)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(yamlFile, &obj)
if err != nil {
return nil, err
}
if err := validator.New().Struct(obj); err != nil {
return nil, err
}
return &obj, nil
}