mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
27 lines
572 B
Go
27 lines
572 B
Go
|
package graffiti
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
|
||
|
"gopkg.in/yaml.v2"
|
||
|
)
|
||
|
|
||
|
type Graffiti struct {
|
||
|
Default string `yaml:"default,omitempty"`
|
||
|
Random []string `yaml:"random,omitempty"`
|
||
|
Specific map[uint64]string `yaml:"specific,omitempty"`
|
||
|
}
|
||
|
|
||
|
// ParseGraffitiFile parses the graffiti file and returns the graffiti struct.
|
||
|
func ParseGraffitiFile(f string) (*Graffiti, error) {
|
||
|
yamlFile, err := ioutil.ReadFile(f)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
g := &Graffiti{}
|
||
|
if err := yaml.Unmarshal(yamlFile, g); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return g, nil
|
||
|
}
|