evaluator: Directly parse yaml file
This commit is contained in:
parent
3304bf1b49
commit
01330f405c
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
|||
bangs.json
|
||||
/evaluator/vendor/
|
||||
|
|
|
@ -13,7 +13,7 @@ RUN go get -v \
|
|||
FROM scratch
|
||||
|
||||
COPY --from=builder /go/src/git.sbruder.de/simon/bangs/evaluator/evaluator /evaluator
|
||||
copy bangs.json /bangs.json
|
||||
COPY bangs.yml /bangs.yml
|
||||
|
||||
USER 1000
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var bangs = loadBangs()
|
||||
|
@ -32,12 +33,12 @@ func main() {
|
|||
}
|
||||
|
||||
func loadBangs() (bangs map[string]string) {
|
||||
data, err := ioutil.ReadFile("bangs.json")
|
||||
data, err := ioutil.ReadFile("bangs.yml")
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read bangs: %v", err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &bangs)
|
||||
err = yaml.Unmarshal(data, &bangs)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to decode bangs: %v", err)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module git.sbruder.de/simon/bangs/evaluator
|
||||
|
||||
go 1.15
|
||||
|
||||
require gopkg.in/yaml.v2 v2.4.0
|
||||
|
|
3
evaluator/go.sum
Normal file
3
evaluator/go.sum
Normal file
|
@ -0,0 +1,3 @@
|
|||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
Loading…
Reference in a new issue