Skip to content

Commit 3f4a4f8

Browse files
authored
fix: when it's method, exported is determined by the Method name but not its receiver (#110)
1 parent a31fd78 commit 3f4a4f8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lang/golang/parser/file.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ func (p *GoParser) parseVar(ctx *fileContext, vspec *ast.ValueSpec, isConst bool
225225

226226
// newFunc allocate a function in the repo
227227
func (p *GoParser) newFunc(mod, pkg, name string) *Function {
228-
ret := &Function{Identity: NewIdentity(mod, pkg, name), Exported: isUpperCase(name[0])}
228+
var exported bool
229+
if ind := strings.LastIndexByte(name, '.'); ind != -1 && ind+1 < len(name) {
230+
exported = isUpperCase(name[ind+1])
231+
} else {
232+
exported = isUpperCase(name[0])
233+
}
234+
235+
ret := &Function{Identity: NewIdentity(mod, pkg, name), Exported: exported}
229236
return p.repo.SetFunction(ret.Identity, ret)
230237
}
231238

0 commit comments

Comments
 (0)