feat: ability to specify a current employment
This commit allows the user to specify a company that they are currently employed at. Changes include: - add present field to the Duration type. - add durationToString function to output the duration type as a formatted string. - if the present field is used and the value is either 'true' or 'yes' (case insensitive) this will be reflected on the CV. - add durationToString to fmap. - updated CV template to use the durationToString function.
This commit is contained in:
parent
e9a2a749f9
commit
04162a27bc
3 changed files with 25 additions and 6 deletions
18
main.go
18
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -24,6 +25,7 @@ func main() {
|
||||||
fmap := template.FuncMap{
|
fmap := template.FuncMap{
|
||||||
"notLastElement": notLastElement,
|
"notLastElement": notLastElement,
|
||||||
"join": join,
|
"join": join,
|
||||||
|
"durationToString": durationToString,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the JSON data
|
// Read the JSON data
|
||||||
|
@ -79,3 +81,19 @@ func notLastElement(pos, length int) bool {
|
||||||
func join(s []string) string {
|
func join(s []string) string {
|
||||||
return strings.Join(s, " ")
|
return strings.Join(s, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// durationToString outputs the employment/education
|
||||||
|
// duration as a formatted string.
|
||||||
|
func durationToString(d Duration) string {
|
||||||
|
start := fmt.Sprintf("%s, %s", d.Start.Month, d.Start.Year)
|
||||||
|
present := strings.ToLower(d.Present)
|
||||||
|
end := ""
|
||||||
|
|
||||||
|
if present == "yes" || present == "true" {
|
||||||
|
end = "Present"
|
||||||
|
} else {
|
||||||
|
end = fmt.Sprintf("%s, %s", d.End.Month, d.End.Year)
|
||||||
|
}
|
||||||
|
|
||||||
|
return start + " - " + end
|
||||||
|
}
|
||||||
|
|
1
model.go
1
model.go
|
@ -43,6 +43,7 @@ type Experience struct {
|
||||||
type Duration struct {
|
type Duration struct {
|
||||||
Start Date `json:"start"`
|
Start Date `json:"start"`
|
||||||
End Date `json:"end"`
|
End Date `json:"end"`
|
||||||
|
Present string `json:"present"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Date struct {
|
type Date struct {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
\section{EXPERIENCE}
|
\section{EXPERIENCE}
|
||||||
<<- range .Employment>>
|
<<- range .Employment>>
|
||||||
\jobsection{<<.Company>>}{<<.Location>>}{<<.JobTitle>>}{<<.Duration.Start.Month>>, <<.Duration.Start.Year>> - <<.Duration.End.Month>>, <<.Duration.End.Year>>}
|
\jobsection{<<.Company>>}{<<.Location>>}{<<.JobTitle>>}{<<durationToString .Duration>>}
|
||||||
\startitemize
|
\startitemize
|
||||||
<<range .Details>>
|
<<range .Details>>
|
||||||
\item <<.>>
|
\item <<.>>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
\section{EDUCATION}
|
\section{EDUCATION}
|
||||||
<<range .Education ->>
|
<<range .Education ->>
|
||||||
\jobsection{<<.School>>}{<<.Location>>}{<<.Qualification>>}{<<.Duration.Start.Month>>, <<.Duration.Start.Year>> - <<.Duration.End.Month>>, <<.Duration.End.Year>>}
|
\jobsection{<<.School>>}{<<.Location>>}{<<.Qualification>>}{<<durationToString .Duration>>}
|
||||||
\startitemize
|
\startitemize
|
||||||
<<range .Details>>
|
<<range .Details>>
|
||||||
\item <<.>>
|
\item <<.>>
|
||||||
|
|
Loading…
Reference in a new issue