I'm writing a code generator from protobuf via templates and i can say -
debugging it is very hard. When you have big files you can't check syntax
easily, don't know how it looks and if you have errors in the template it
is really hard to fix them.
So the protoc-gen-go case is preferable.

вс, 19 сент. 2021 г. в 04:33, Denis Cheremisov <denis.cheremi...@gmail.com>:

> Templates is the worst approach to code generation IMO. Take a look how
> they do this in protoc-gen-go:
>
> https://github.com/protocolbuffers/protobuf-go/blob/b92717ecb630d4a4824b372bf98c729d87311a4d/cmd/protoc-gen-go/internal_gengo/main.go#L83
>
> I am using very similar approach, albeit I prefer format lines, it looks
> like:
> [image: Screenshot from 2021-09-19 04-22-26.png]
>
> Templates may be OK only in trivial cases. Once you need something less
> trivial it is getting harder and harder to reason how the final code will
> look like with them
> and you will end up with bunch of hard to manage templates. Unlike it,
> line-by-line code generation keep staying close to the final code.
> вторник, 7 сентября 2021 г. в 22:53:51 UTC+3, amitl...@gmail.com:
>
>>
>> Hi gophers,
>> I wrote https://github.com/fluhus/goat for generating go code in my
>> projects. I hope it can help you too. It's a minimal tool that takes a
>> text/template <https://pkg.go.dev/text/template> template as input, runs
>> it on the given parameters and gofmt's the output. You can also use it on
>> non-go-source.
>> Feedback is welcome.
>>
>> Amit
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/406179d9-c8f5-497d-8832-ea04ff9d03b3n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/406179d9-c8f5-497d-8832-ea04ff9d03b3n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACaajQuOEDr0zyLeS8%3Dm9Xiy1AU12YkqoMtzVkVueaJmbXQ8XA%40mail.gmail.com.

Reply via email to