Skip to content

Conversation

@picatz
Copy link
Owner

@picatz picatz commented Jul 4, 2025

Summary

  • recursively traverse newly discovered functions when building call graph
  • added test ensuring struct function fields are recognized

Testing

  • go test ./...

https://chatgpt.com/codex/tasks/task_e_6867011b30b8833186aeb5dd0b7928b0

@picatz
Copy link
Owner Author

picatz commented Jul 4, 2025

Very cool, I can see it finds the path:

type command struct {
name string
run func(args []string) error
}
type commands []*command
func (c commands) run(args []string) error {
for i := 0; i < len(c); i++ {
cmd := c[i]
if cmd.name == args[0] {
return cmd.run(args[1:])
}
}
return fmt.Errorf("unknown command: %s", args[0])
}
type cli struct {
commands commands
}
func (c *cli) run(args []string) error {
return c.commands.run(args)
}
func doSomething() error {
fmt.Println("doing something")
return nil
}
func main() {
c := &cli{
commands{
{
name: "do-something",
run: func(args []string) error {
return doSomething()
},
},
},
}
if err := c.run(os.Args[1:]); err != nil {
panic(err)
}
}

n0:main → n4:(*cli).run → n5:(commands).run → n2:main$1 → n1:doSomething

@picatz picatz merged commit bdda215 into main Jul 4, 2025
1 check passed
@picatz picatz deleted the codex/fix-issue-#23-based-on-pr-#38 branch July 4, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants