github.com/jacekolszak/noteo@v0.5.0/repository/config.go (about)

     1  package repository
     2  
     3  import (
     4  	"io/ioutil"
     5  
     6  	"gopkg.in/yaml.v2"
     7  )
     8  
     9  func parse(file string) (*Config, error) {
    10  	c := &Config{}
    11  	bytes, err := ioutil.ReadFile(file)
    12  	if err != nil {
    13  		return nil, err
    14  	}
    15  	if err = yaml.Unmarshal(bytes, c); err != nil {
    16  		return nil, err
    17  	}
    18  	return c, nil
    19  }
    20  
    21  type Config struct {
    22  	Editor string `yaml:"editor"`
    23  }
    24  
    25  func (r *Config) EditorCommand() string {
    26  	return r.Editor
    27  }