mirror of
https://github.com/gusaul/grpcox.git
synced 2025-01-24 21:24:39 +00:00
Merge pull request #36 from beruangcoklat/master
handle error when remove and create directory
This commit is contained in:
commit
f240d0494e
|
@ -285,8 +285,14 @@ func (r *Resource) AddProtos(protos []Proto) error {
|
||||||
protoPath := filepath.Join(BasePath, r.clientConn.Target())
|
protoPath := filepath.Join(BasePath, r.clientConn.Target())
|
||||||
err := os.MkdirAll(protoPath, 0777)
|
err := os.MkdirAll(protoPath, 0777)
|
||||||
if os.IsExist(err) {
|
if os.IsExist(err) {
|
||||||
os.RemoveAll(protoPath)
|
err = os.RemoveAll(protoPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
err = os.MkdirAll(protoPath, 0777)
|
err = os.MkdirAll(protoPath, 0777)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func Test_prepareImport(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if got := prepareImport(tt.args.proto, ""); !reflect.DeepEqual(got, tt.want) {
|
if got := prepareImport(tt.args.proto); !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("prepareImport() = %v, want %v",
|
t.Errorf("prepareImport() = %v, want %v",
|
||||||
string(got),
|
string(got),
|
||||||
string(tt.want))
|
string(tt.want))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user