Dan Anglin
fa8dbe68e9
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.
25 lines
436 B
Go
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
|
|
}
|