1
0
mirror of https://github.com/gusaul/grpcox.git synced 2024-09-29 04:10:39 +00:00

Merge pull request #36 from beruangcoklat/master

handle error when remove and create directory
This commit is contained in:
Muhammad Auliya 2022-10-18 17:38:06 +07:00 committed by GitHub
commit f240d0494e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -285,8 +285,14 @@ func (r *Resource) AddProtos(protos []Proto) error {
protoPath := filepath.Join(BasePath, r.clientConn.Target())
err := os.MkdirAll(protoPath, 0777)
if os.IsExist(err) {
os.RemoveAll(protoPath)
err = os.RemoveAll(protoPath)
if err != nil {
return err
}
err = os.MkdirAll(protoPath, 0777)
if err != nil {
return err
}
} else if err != nil {
return err
}

View File

@ -60,7 +60,7 @@ func Test_prepareImport(t *testing.T) {
}
for _, tt := range tests {
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",
string(got),
string(tt.want))