Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtsts-server-go
This commit is contained in:
commit
de5bf8b82a
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -25,23 +26,25 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取指定文件夹下的所有proto文件的绝对路径列表
|
// 获取指定文件夹下的所有proto文件的绝对路径
|
||||||
func getProtoFiles() []string {
|
func getProtoFiles() []string {
|
||||||
var protoFiles []string
|
var protoFiles []string
|
||||||
files, err := os.ReadDir(protoFolder)
|
err := filepath.WalkDir(protoFolder, func(path string, d fs.DirEntry, err error) error {
|
||||||
|
if !d.IsDir() {
|
||||||
|
protoFiles = append(protoFiles, path)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("获取proto文件列表失败")
|
log.Fatal("获取proto文件列表失败:", err)
|
||||||
}
|
|
||||||
for _, file := range files {
|
|
||||||
protoFiles = append(protoFiles, file.Name())
|
|
||||||
}
|
}
|
||||||
return protoFiles
|
return protoFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编译proto文件为Go文件
|
// 编译proto文件为Go文件
|
||||||
func compileProto(protoFiles []string) error {
|
func compileProto(protoFiles []string) error {
|
||||||
for _, protoFile := range protoFiles {
|
for _, fileName := range protoFiles {
|
||||||
cmd := exec.Command(protocPath, "--proto_path="+protoFolder, "--go_out=./", protoFile)
|
cmd := exec.Command(protocPath, "-I="+protoFolder, "--go_out=./", fileName)
|
||||||
fmt.Println(cmd.String())
|
fmt.Println(cmd.String())
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
Loading…
Reference in New Issue