package main

import (
	"html/template"
	"log"
	"os"
	"time"
)

// Must method parses the template to ensure no errors;
// New method creates and returns a new template
var report = template.Must(template.New("issuelist").Parse(IssueList))

func main() {
	result, err := SearchIssues(os.Args[1:])
	if err != nil {
		log.Fatal(err)
	}
	if err := report.Execute(os.Stdout, result); err != nil {
		log.Fatal(err)
	}
}

func daysAgo(t time.Time) int {
	return int(time.Since(t).Hours() / 24)
}

package main

import (
	"html/template"
	"log"
	"os"
	"time"
)

// Must method parses the template to ensure no errors;
// New method creates and returns a new template
var report = template.Must(template.New("issuelist").

	// Funcs adds daysAgo as a function accessible inside the template
	Funcs(template.FuncMap{"daysAgo": daysAgo}).Parse(IssueList))

func main() {
	result, err := SearchIssues(os.Args[1:])
	if err != nil {
		log.Fatal(err)
	}
	if err := report.Execute(os.Stdout, result); err != nil {
		log.Fatal(err)
	}
}

func daysAgo(t time.Time) int {
	return int(time.Since(t).Hours() / 24)
}

Add daysAgo func to template
Add daysAgo func to template
