company facts simple read out of xls works
This commit is contained in:
@@ -1,10 +1,28 @@
|
||||
package loader
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
)
|
||||
|
||||
//go:embed conf/default.json
|
||||
var defaultConf []byte
|
||||
|
||||
// DefaultConf loads the defaultConf of the package. The base
|
||||
// is the default.json inside the package definition.
|
||||
func DefaultConf() *Conf {
|
||||
buf := bytes.NewBuffer(defaultConf)
|
||||
conf := &Conf{}
|
||||
err := conf.DecodeJSON(buf)
|
||||
if err != nil {
|
||||
log.Println("cannot decode default conf: ", err)
|
||||
}
|
||||
return conf
|
||||
}
|
||||
|
||||
// Conf configures the mapping from the excel version
|
||||
// to the eCalc structure
|
||||
type Conf struct {
|
||||
@@ -15,6 +33,20 @@ type Conf struct {
|
||||
Rating Rating `json:"rating"`
|
||||
}
|
||||
|
||||
// EncodeJSON writes the JSON of the conf into the Writer
|
||||
func (c Conf) EncodeJSON(w io.Writer) error {
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(c)
|
||||
}
|
||||
|
||||
// DecodeJSON writes the configuration from the reader into
|
||||
// the pointer of the conf
|
||||
func (c *Conf) DecodeJSON(r io.Reader) error {
|
||||
dec := json.NewDecoder(r)
|
||||
return dec.Decode(c)
|
||||
}
|
||||
|
||||
// Value defines a single value inside the excel workbook
|
||||
type Value struct {
|
||||
Sheet int `json:"sheet"`
|
||||
@@ -61,17 +93,3 @@ type Rating struct {
|
||||
WeightCol string `json:"weight_col"`
|
||||
SelectedByUserCol string `json:"selected_by_user_col"`
|
||||
}
|
||||
|
||||
// EncodeJSON writes the JSON of the conf into the Writer
|
||||
func (c Conf) EncodeJSON(w io.Writer) error {
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(c)
|
||||
}
|
||||
|
||||
// DecodeJSON writes the configuration from the reader into
|
||||
// the pointer of the conf
|
||||
func (c *Conf) DecodeJSON(r io.Reader) error {
|
||||
dec := json.NewDecoder(r)
|
||||
return dec.Decode(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user