Sha256: 744cf2c09ffb6ec8284033eda0ec5c6778952c678d432a916207d53c34e641e9
Contents?: true
Size: 976 Bytes
Versions: 67
Compression:
Stored size: 976 Bytes
Contents
// +build ignore package main import ( "log" "strings" "text/template" "../../gen" ) func main() { m := template.FuncMap{"week": strings.Title} t, err := template.New("").Funcs(m).Parse(tmpl) if err != nil { log.Fatal(err) } var j js if err := gen.Gen("meetup.json", &j, t); err != nil { log.Fatal(err) } } // The JSON structure we expect to be able to unmarshal into type js struct { Cases []struct { Description string Year int Month int Week string Dayofweek string Dayofmonth int } } // template applied to above data structure generates the Go test cases var tmpl = `package meetup // Source: {{.Ori}} {{if .Commit}}// Commit: {{.Commit}} {{end}} import "time" var testCases = []struct { year int month time.Month week WeekSchedule weekday time.Weekday expDay int }{ {{range .J.Cases}}{ {{.Year}}, {{.Month}}, {{week .Week}}, time.{{.Dayofweek}}, {{.Dayofmonth}}}, // {{.Description}} {{end}}} `
Version data entries
67 entries across 67 versions & 1 rubygems