golang protobuf remove omitempty tag from generated json tags

后端 未结 7 1318
余生分开走
余生分开走 2021-02-04 00:00

I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files.

if i have a pr

7条回答
  •  醉酒成梦
    2021-02-04 00:19

    You could use "sed" command to remove this text from files like following

    sed -i "" -e "s/,omitempty//g" ./api/proto/*.go
    

    where args:

    1. -i "" is meaning that keep same name of files
    2. -e "s/,omitempty//g" = format to replace like "s/SEARCH/INSERT/g"

提交回复
热议问题