goctl add plugin support (#243)

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* add plugin support

* remove no need

* add plugin support

* rename

* rename

* add plugin support

* refactor

* update plugin

* refactor

* refactor

* refactor

* update plugin

* newline

Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
This commit is contained in:
kingxt
2020-12-07 14:55:10 +08:00
committed by GitHub
parent 7cd0463953
commit cecd4b1b75
5 changed files with 224 additions and 1 deletions

View File

@@ -12,7 +12,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/vars"
)
func Run(arg string, dir string) (string, error) {
func Run(arg string, dir string, in ...*bytes.Buffer) (string, error) {
goos := runtime.GOOS
var cmd *exec.Cmd
switch goos {
@@ -28,6 +28,9 @@ func Run(arg string, dir string) (string, error) {
}
stdout := new(bytes.Buffer)
stderr := new(bytes.Buffer)
if len(in) > 0 {
cmd.Stdin = in[0]
}
cmd.Stdout = stdout
cmd.Stderr = stderr
err := cmd.Run()