Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go implementation #78

Open
cwize1 opened this issue Dec 23, 2020 · 9 comments
Open

Go implementation #78

cwize1 opened this issue Dec 23, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@cwize1
Copy link

cwize1 commented Dec 23, 2020

In case anyone is interested, I am currently working on adding Go support. Though fair warning: I am doing this for fun over my staycation and I currently don't have any plans to use it in any sort of production code.

I am uploading my changes as I go here: cwize1/Go.

It is still a work in progress. But I have made enough progress on it that I feel confident that I'll be able to have it mostly completed by the end of the year.

@cwize1 cwize1 added the enhancement New feature or request label Dec 23, 2020
@200sc
Copy link

200sc commented Dec 24, 2020

@cwize1 If you'd like a reference implementation, you may be interested in one I've written that I consider complete: https://github.com/200sc/bebop

@andrewmd5
Copy link
Contributor

You're both awesome! Thanks for your contributions, @200sc seeing someone reimplement the entirety of Bebop is really humbling.

@cwize1 if you have any feedback on how we can improve the code generation API don't hesitate to share it. We've knocked back and forth the idea of our own template engine and also just extending it to be script-based so iterating is faster.

@cwize1
Copy link
Author

cwize1 commented Dec 25, 2020

bebopc was pretty easy to integrate a new language generator into. Having the schema's info parsed into a nice object hierarchy made it pretty easy to focus on writing the Go specific code.

bebopc's bespoke command line arguments system took me a little bit to figure out. But it wasn't too difficult in the end to add the relevant options needed for Go. Though it would be nice if the option names used in the CLI and the config file were consistent.

I am not sure a template engine would have helped much. As a language, Go has a lot of strong opinions and unique ways of doings things. So, I am not sure how much its implementation could be shared with other languages. So, I think what you have at the moment is fine.

Of possible interest is that I implemented array and map encoding/decoding in a completely different way to what was done in the other languages. Instead of encoding/decoding maps and arrays inline within the struct/message's encode/decode functions, I created separate encode/decode functions for each nameless type used within the schema. This helped reduce the mental gymnastics required to write the encode/decode functions and also avoids duplicating code in the generated code.

@andrewmd5
Copy link
Contributor

Hey @cwize1 just as a heads up a new type was added in 2.1.0.

@cwize1
Copy link
Author

cwize1 commented Feb 15, 2021

I've completed updating my Go implementation to support unions.

@andrewmd5
Copy link
Contributor

I've completed updating my Go implementation to support unions.

Sorry for the delay in replying, great work! I’m not fluent in Go but if you want to submit a pull-request will find the right person to review it.

@cwize1
Copy link
Author

cwize1 commented Mar 8, 2021

While I am happy to open a PR, I can't provide any guarantees that I'll always be available to provide support and maintenance. I did this project just for fun and will probably only continue working on it so long as it remains fun and it doesn't interfere with my day job.

@therathatter
Copy link

therathatter commented Jun 7, 2024

As of writing this, the documentation states it works with Go, as seen here:

https://docs.bebop.sh/guide/getting-started/#supported-languages
image

Despite this, the latest version of bebopc states it has no generator with the alias 'go'. Am I doing something wrong here? There is no documentation for actually generating Go code, so I am assuming it is not actually supported, and if that is the case, I am confused why it is stated to be supported in the docs. 200sc's reference implementation does work for me, but the docs imply that it is officially supported, not mentioning the unofficial implementation.

@andrewmd5
Copy link
Contributor

andrewmd5 commented Jun 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants