spruce/internal/cv/cv.go
Dan Anglin fa8dbe68e9
feat(BREAKING): limit shown employment history
Allow users to limit the amount of employment history shown in the PDF
document by specifying a time range. This is a breaking change as the
structure of the CV needs to slightly change. The employment's start and
end dates need to be represented as integers.

Additional refactoring:

- The CV type is now in the internal cv package.
- The template functions are now in the internal templateFuncs package.
2023-03-02 17:40:04 +00:00

25 lines
436 B
Go

package cv
import (
"os"
"fmt"
"encoding/json"
)
// NewCV returns a new CV value from the given JSON file.
func NewCV(path string) (CV, error) {
file, err := os.Open(path)
if err != nil {
return CV{}, fmt.Errorf("unable to open %s; %w", path, err)
}
decoder := json.NewDecoder(file)
var c CV
if err = decoder.Decode(&c); err != nil {
return CV{}, fmt.Errorf("unable to decode JSON data; %w", err)
}
return c, nil
}