spruce/template_funcs.go
Dan Anglin 11b9d4df15
feat: new cv builder tool
New CV builder tool migrated from the private repository.
2023-02-18 21:01:28 +00:00

34 lines
748 B
Go

package main
import (
"fmt"
"strings"
)
// notLastElement returns true if an element of an array
// or a slice is not the last.
func notLastElement(pos, length int) bool {
return pos < length-1
}
// join uses strings.Join to join all string elements into
// a single string.
func join(s []string) string {
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
}