riita10069 / roche

Roche is a Code Generator and Web Framework, makes web development super concise with Go, CleanArch
MIT License
14 stars 0 forks source link

Domain objects are not created properly from proto file #9

Open 0x-shanks opened 3 years ago

0x-shanks commented 3 years ago

Describe the bug Running roche scaffold domain NAME after editing a Proto file creates a domain object with fields that are not the edited ones.

for example user.proto

message User {
  string id = 1;
  string name = 2;
}

but

domain/entity/user.go

type User struct {
    UserId string
    XXX_NoUnkeyedLiteral
    XXX_unrecognized
    XXX_sizecache int32
}

Expected behavior domain/entity/user.go

type User struct {
    Id string
    name string
}
riita10069 commented 3 years ago

Thanks for the report. I can't reproduce that on my local Mac Book.

Did you run protoc after updating the .proto? roche is internally looking at the pb.go structure. Or are you not using the latest version of roche?

0x-shanks commented 3 years ago

I'm sorry, I didn't run the roche protoc command, I forgot it wasn't in the readme!

0x-shanks commented 3 years ago

I just don't get an error message when I run the roche protoc, so I'll have to make that an issue.

riita10069 commented 3 years ago

The current roche protoc has the following problems. https://github.com/izumin5210/grapi/issues/130 Therefore, it is not described in the readme.

Strictly speaking, tools.go has the potential ability to solve the problem.

0x-shanks commented 3 years ago

I think we've talked about this issue before.

In my environment, when I used grapi v0.5.0, I got an error, but the grapi that roche depends on is a later version, right?

Example of error output of grapi v0.5.0

  ➜  Execute protoc
  ▸  Install plugins
  ▸  Execute protoc
     ✗  api/protos/user.proto
        failed to execute command: [protoc -I api/protos -I ./api/protos -I /workspace/github.com/grpc-ecosystem/grpc-gateway@v1.16.0 -I /workspace/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.16.0/third_party/googleapis --grpc-gateway_out=logtostderr=true,paths=source_relative:api api/protos/user.proto]
        --grpc-gateway_out: no field "id" found in UpdateUserRequest
        : exit status 1

roche protoc

  ➜  Execute protoc
  ▸  Install plugins
  ▸  Execute protoc
     ✔  api/protos/user.proto