summaryrefslogtreecommitdiff
path: root/model/run.go
blob: 9329708bd9a8848243e3edb151425073f9afc6ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package model

import (
	"crypto/md5"
	"encoding/hex"
	"encoding/json"
)

type Run struct {
	RunSave
	RunId string
}

func NewRun(fileContent []byte) (Run, error) {
	var save RunSave
	err := json.Unmarshal(fileContent, &save)
	sum := md5.Sum(fileContent)
	r := Run{RunId: hex.EncodeToString(sum[:]), RunSave: save}
	if err != nil {
		return r, err
	}

	return r, nil
}