Code generation in Go
Answered
I'm working on a plugin that should generate Go code. I did not manage to find good examples of code generating plugins that work with Go. But I found one that do it in Kotlin. It uses `org.jetbrains.kotlin.psi.KtPsiFactory` to create all PsiElements. I want to know if there is similarly working factory for Go PsiElements? Or you probably can point a different approach? It would be great if you could share some example.
Please sign in to leave a comment.
Hi Nikolay,
Thank you for contributing and your interest in the IntelliJ plugin development ecosystem.
A good entry point would be: https://plugins.jetbrains.com/docs/intellij/goland.html (at the bottom there are a few open-source examples).
Other examples are the following:
- https://github.com/Enokiy/go-struct-to-json-intellij-plugin (generates something according to PSI)
- https://github.com/xxpxxxxp/intellij-plugin-golangci-lint (example of a complex plugin)
In Go, an alternative to
org.jetbrains.kotlin.psi.KtPsiFactory
iscom.goide.psi.impl.GoElementFactory
which provides similar entrypoints.