@@ -19,6 +19,7 @@ import (
1919)
2020
2121type Runner struct {
22+ GoPkg string
2223 Cmd string
2324 Format string
2425 Env []string
@@ -53,13 +54,27 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,
5354 return fmt .Errorf ("unknown plugin format: %s" , r .Format )
5455 }
5556
56- // Check if the output plugin exists
57- path , err := exec .LookPath (r .Cmd )
58- if err != nil {
59- return fmt .Errorf ("process: %s not found" , r .Cmd )
57+ var cmd * exec.Cmd
58+ switch {
59+ case r .Cmd != "" && r .GoPkg == "" :
60+ // Check if the output plugin exists
61+ path , err := exec .LookPath (r .Cmd )
62+ if err != nil {
63+ return fmt .Errorf ("process: %s not found" , r .Cmd )
64+ }
65+ cmd = exec .CommandContext (ctx , path , method )
66+ case r .Cmd == "" && r .GoPkg != "" :
67+ // Check if the output plugin exists
68+ path , err := exec .LookPath ("go" )
69+ if err != nil {
70+ return fmt .Errorf ("go binary required to run go package %s" , r .GoPkg )
71+ }
72+ cmd = exec .CommandContext (ctx , path , method )
73+ cmd .Args = []string {"run" , r .GoPkg }
74+ default :
75+ return fmt .Errorf ("cmd and go_package cannot both be empty for process plugin" )
6076 }
6177
62- cmd := exec .CommandContext (ctx , path , method )
6378 cmd .Stdin = bytes .NewReader (stdin )
6479 cmd .Env = []string {
6580 fmt .Sprintf ("SQLC_VERSION=%s" , info .Version ),
0 commit comments