// Parse the output of the "go build" command. // Return a detailed Error. func newCompileError(output []byte) *revel.Error { errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`). FindSubmatch(output) if errorMatch == nil { revel.ERROR.Println("Failed to parse build errors:\n", string(output)) return &revel.Error{ SourceType: "Go code", Title: "Go Compilation Error", Description: "See console for build error.", } } // Read the source for the offending file. var ( relFilename = string(errorMatch[1]) // e.g. "src/revel/sample/app/controllers/app.go" absFilename, _ = filepath.Abs(relFilename) line, _ = strconv.Atoi(string(errorMatch[2])) description = string(errorMatch[4]) compileError = &revel.Error{ SourceType: "Go code", Title: "Go Compilation Error", Path: relFilename, Description: description, Line: line, } ) fileStr, err := revel.ReadLines(absFilename) if err != nil { compileError.MetaError = absFilename + ": " + err.Error() revel.ERROR.Println(compileError.MetaError) return compileError } compileError.SourceLines = fileStr return compileError }
func (mustmpl MustacheTemplate) Content() []string { content, _ := revel.ReadLines(mustmpl.loader.templatePaths[mustmpl.Name()]) return content }