Changed the local code walker to include all go files in the base path, and not just the app path

This commit is contained in:
notzippy@gmail.com
2020-07-14 12:45:10 -07:00
parent ebc9c73ba0
commit c7f4307a5d
2 changed files with 12 additions and 11 deletions

View File

@@ -458,7 +458,7 @@ func newCompileError(paths *model.RevelContainer, output []byte) *utils.SourceEr
return compileError return compileError
} }
// RevelMainTemplate template for app/tmp/main.go // RevelMainTemplate template for app/tmp/run/run.go
const RevelRunTemplate = `// GENERATED CODE - DO NOT EDIT const RevelRunTemplate = `// GENERATED CODE - DO NOT EDIT
// This file is the run file for Revel. // This file is the run file for Revel.
// It registers all the controllers and provides details for the Revel server engine to // It registers all the controllers and provides details for the Revel server engine to

View File

@@ -12,7 +12,6 @@ import (
"go/ast" "go/ast"
"go/token" "go/token"
"go/scanner" "go/scanner"
) )
type ( type (
@@ -111,9 +110,8 @@ func (s *SourceProcessor) addPackages() (err error) {
s.packageList, err = packages.Load(config, allPackages...) s.packageList, err = packages.Load(config, allPackages...)
s.log.Info("Loaded modules ", "len results", len(s.packageList), "error", err) s.log.Info("Loaded modules ", "len results", len(s.packageList), "error", err)
// Now process the files in the aap source folder s.revelContainer.ImportPath + "/...", // Now process the files in the aap source folder s.revelContainer.ImportPath + "/...",
err = utils.Walk(s.revelContainer.AppPath, s.processPath) err = utils.Walk(s.revelContainer.BasePath, s.processPath)
s.log.Info("Loaded apps and modules ", "len results", len(s.packageList), "error", err) s.log.Info("Loaded apps and modules ", "len results", len(s.packageList), "error", err)
return return
} }
@@ -138,6 +136,8 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
if appPath != path { if appPath != path {
pkgImportPath = s.revelContainer.ImportPath + "/" + filepath.ToSlash(path[len(appPath) + 1:]) pkgImportPath = s.revelContainer.ImportPath + "/" + filepath.ToSlash(path[len(appPath) + 1:])
} }
s.log.Info("Processing source package folder", "package", pkgImportPath, "path", path)
// Parse files within the path. // Parse files within the path.
var pkgMap map[string]*ast.Package var pkgMap map[string]*ast.Package
fset := token.NewFileSet() fset := token.NewFileSet()
@@ -173,6 +173,7 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
ast.Print(nil, err) ast.Print(nil, err)
s.log.Fatal("Failed to parse dir", "error", err) s.log.Fatal("Failed to parse dir", "error", err)
} }
// Skip "main" packages. // Skip "main" packages.
delete(pkgMap, "main") delete(pkgMap, "main")
@@ -194,7 +195,7 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
// There should be only one package in this directory. // There should be only one package in this directory.
if len(pkgMap) > 1 { if len(pkgMap) > 1 {
for i := range pkgMap { for i := range pkgMap {
println("Found package ", i) println("Found duplicate packages in single directory ", i)
} }
utils.Logger.Fatal("Most unexpected! Multiple packages in a single directory:", "packages", pkgMap) utils.Logger.Fatal("Most unexpected! Multiple packages in a single directory:", "packages", pkgMap)
} }