diff --git a/tools/goctl/rpc/generator/gen_test.go b/tools/goctl/rpc/generator/gen_test.go index cd9ee2d0..948cb1e0 100644 --- a/tools/goctl/rpc/generator/gen_test.go +++ b/tools/goctl/rpc/generator/gen_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/stringx" conf "github.com/tal-tech/go-zero/tools/goctl/config" @@ -45,7 +46,7 @@ func TestRpcGenerate(t *testing.T) { // case go path t.Run("GOPATH", func(t *testing.T) { - err = g.Generate("./test.proto", projectDir, []string{common, src}, "Mbase/common.proto=./base") + err = g.Generate("./test.proto", projectDir, []string{common}, "Mbase/common.proto=./base") assert.Nil(t, err) _, err = execx.Run("go test "+projectName, projectDir) if err != nil { @@ -66,7 +67,7 @@ func TestRpcGenerate(t *testing.T) { } projectDir = filepath.Join(workDir, projectName) - err = g.Generate("./test.proto", projectDir, []string{common, src}, "Mbase/common.proto=./base") + err = g.Generate("./test.proto", projectDir, []string{common}, "Mbase/common.proto=./base") assert.Nil(t, err) _, err = execx.Run("go test "+projectName, projectDir) if err != nil { diff --git a/tools/goctl/rpc/generator/test.proto b/tools/goctl/rpc/generator/test.proto index c2746107..5ee8ae40 100644 --- a/tools/goctl/rpc/generator/test.proto +++ b/tools/goctl/rpc/generator/test.proto @@ -4,14 +4,11 @@ syntax = "proto3"; package test; import "base/common.proto"; -import "google/protobuf/any.proto"; - option go_package = "github.com/test"; message Req { string in = 1; common.User user = 2; - google.protobuf.Any object = 4; } message Reply { diff --git a/tools/goctl/util/path.go b/tools/goctl/util/path.go index 0ac3b1cf..c997396a 100644 --- a/tools/goctl/util/path.go +++ b/tools/goctl/util/path.go @@ -121,8 +121,13 @@ func ReadLink(name string) (string, error) { return "", err } - if name == "/" { - return "/", nil + if _, err := os.Lstat(name); err != nil { + return name, nil + } + + // uncheck condition: ignore file path /var, maybe be temporary file path + if name == "/" || name == "/var" { + return name, nil } isLink, err := isLink(name)