Id should be ID (golint)

This commit is contained in:
Noah Zoschke 2018-01-26 08:48:48 -08:00
parent 116b4c7341
commit 13a5dea6a7

View File

@ -127,7 +127,7 @@ type Seg struct {
// Example is info extracted from an example file // Example is info extracted from an example file
type Example struct { type Example struct {
Id, Name string ID, Name string
GoCode, GoCodeHash, UrlHash string GoCode, GoCodeHash, UrlHash string
Segs [][]*Seg Segs [][]*Seg
NextExample *Example NextExample *Example
@ -222,14 +222,14 @@ func parseExamples() []*Example {
for _, exampleName := range exampleNames { for _, exampleName := range exampleNames {
if (exampleName != "") && !strings.HasPrefix(exampleName, "#") { if (exampleName != "") && !strings.HasPrefix(exampleName, "#") {
example := Example{Name: exampleName} example := Example{Name: exampleName}
exampleId := strings.ToLower(exampleName) exampleID := strings.ToLower(exampleName)
exampleId = strings.Replace(exampleId, " ", "-", -1) exampleID = strings.Replace(exampleID, " ", "-", -1)
exampleId = strings.Replace(exampleId, "/", "-", -1) exampleID = strings.Replace(exampleID, "/", "-", -1)
exampleId = strings.Replace(exampleId, "'", "", -1) exampleID = strings.Replace(exampleID, "'", "", -1)
exampleId = dashPat.ReplaceAllString(exampleId, "-") exampleID = dashPat.ReplaceAllString(exampleID, "-")
example.Id = exampleId example.ID = exampleID
example.Segs = make([][]*Seg, 0) example.Segs = make([][]*Seg, 0)
sourcePaths := mustGlob("examples/" + exampleId + "/*") sourcePaths := mustGlob("examples/" + exampleID + "/*")
for _, sourcePath := range sourcePaths { for _, sourcePath := range sourcePaths {
if strings.HasSuffix(sourcePath, ".hash") { if strings.HasSuffix(sourcePath, ".hash") {
example.GoCodeHash, example.UrlHash = parseHashFile(sourcePath) example.GoCodeHash, example.UrlHash = parseHashFile(sourcePath)
@ -243,7 +243,7 @@ func parseExamples() []*Example {
} }
newCodeHash := sha1Sum(example.GoCode) newCodeHash := sha1Sum(example.GoCode)
if example.GoCodeHash != newCodeHash { if example.GoCodeHash != newCodeHash {
example.UrlHash = resetUrlHashFile(newCodeHash, example.GoCode, "examples/"+example.Id+"/"+example.Id+".hash") example.UrlHash = resetUrlHashFile(newCodeHash, example.GoCode, "examples/"+example.ID+"/"+example.ID+".hash")
} }
examples = append(examples, &example) examples = append(examples, &example)
} }
@ -270,7 +270,7 @@ func renderExamples(examples []*Example) {
_, err := exampleTmpl.Parse(mustReadFile("templates/example.tmpl")) _, err := exampleTmpl.Parse(mustReadFile("templates/example.tmpl"))
check(err) check(err)
for _, example := range examples { for _, example := range examples {
exampleF, err := os.Create(siteDir + "/" + example.Id) exampleF, err := os.Create(siteDir + "/" + example.ID)
check(err) check(err)
exampleTmpl.Execute(exampleF, example) exampleTmpl.Execute(exampleF, example)
} }