Skip to content

Commit

Permalink
Graceful handling for go.mod file (#35)
Browse files Browse the repository at this point in the history
Graceful handling for go.mod file if the module name is not present.
  • Loading branch information
pandurangpatil authored Apr 19, 2024
1 parent acc4c80 commit 1d6d622
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions goastgen/modfileparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ func (mod *ModFile) Parse() (string, error) {
}
objMap["node_filename"] = mod.File
module := make(map[string]interface{})
module["Name"] = modFile.Module.Mod.Path
module["node_line_no"] = modFile.Module.Syntax.Start.Line
module["node_col_no"] = modFile.Module.Syntax.Start.LineRune
module["node_line_no_end"] = modFile.Module.Syntax.End.Line
module["node_col_no_end"] = modFile.Module.Syntax.End.LineRune
module["node_type"] = "mod.Module"
if modFile.Module != nil {
module["Name"] = modFile.Module.Mod.Path
module["node_line_no"] = modFile.Module.Syntax.Start.Line
module["node_col_no"] = modFile.Module.Syntax.Start.LineRune
module["node_line_no_end"] = modFile.Module.Syntax.End.Line
module["node_col_no_end"] = modFile.Module.Syntax.End.LineRune
module["node_type"] = "mod.Module"
} else {
module["Name"] = mod.File
module["node_line_no"] = 0
module["node_col_no"] = 0
module["node_line_no_end"] = 0
module["node_col_no_end"] = 0
module["node_type"] = "mod.Module"
}
objMap["Module"] = module
dependencies := []interface{}{}
for _, req := range modFile.Require {
Expand Down

0 comments on commit 1d6d622

Please sign in to comment.