Dan Anglin
71d62ecaf6
Add golangci-lint for linting and refactor the code based on the feedback from running it. Changes: - Add configuration for golangci-lint. - Break the large function in create.go into smaller ones. - Rename internal/templateFuncs to internal/templatefuncs to remove upper case letters in the package name. - Add a mage target for lint tests.
36 lines
691 B
Go
36 lines
691 B
Go
package templatefuncs
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"codeflow.dananglin.me.uk/apollo/spruce/internal/cv"
|
|
)
|
|
|
|
// FormatDuration outputs the employment/education
|
|
// duration as a formatted string.
|
|
func FormatDuration(duration cv.Duration) string {
|
|
var start string
|
|
|
|
startDate, err := duration.Start.Parse()
|
|
|
|
if err != nil {
|
|
start = "Unknown"
|
|
} else {
|
|
start = fmt.Sprintf("%s, %d", startDate.Month().String(), startDate.Year())
|
|
}
|
|
|
|
var end string
|
|
|
|
if duration.Present {
|
|
end = "Present"
|
|
} else {
|
|
endDate, err := duration.End.Parse()
|
|
if err != nil {
|
|
end = "Unknown"
|
|
} else {
|
|
end = fmt.Sprintf("%s, %d", endDate.Month().String(), endDate.Year())
|
|
}
|
|
}
|
|
|
|
return start + " - " + end
|
|
}
|