There are packages to scan/parse/typecheck Go code, but what about optimizations?
Suppose we have a program that translates Go to the other target language. If we do it only based on the AST, we will miss all optimizations (unless we apply them by hand). Target environment can have really bad or no optimizer at all, and of course even if it has one, it could not be able to optimize transcompiled code well.
Simply put: what are our options?
Maybe there is some way to compile Go to its assembler with optimizations and then (either of 2):
a) translate assembler back to Go and traverse AST as usual?
b) read assembler into some kind of IR structure and use that to emit code?
Thanks in advance.