go2hx

samples

docs

api

github



Open source Haxe compiler

Import Go libraries in your Haxe projects

Get started!

Standard Library compatibility
modulehlinterpjsinfo
bufio❌ log 76/79imports
bytesimports
compress/bzip2❌ log 3/4❌ log 3/4❌ log 3/4imports
container/heapimports
container/listimports
container/ringimports
context❌ error❌ error❌ errorimports
cryptoimports
crypto/aes❌ log 10/13❌ log 10/13❌ log 10/13imports
crypto/cipher❌ log 3/14❌ log 3/14❌ log 3/14imports
crypto/des❌ log 2/18❌ log 6/18❌ log 2/18imports
crypto/md5❌ log 2/6❌ log 2/6❌ log 3/6imports
crypto/rand❌ error❌ error❌ errorimports
crypto/sha1❌ log 5/7❌ log 5/7❌ log 5/7imports
crypto/sha256❌ log 7/9❌ log 7/9❌ log 7/9imports
crypto/sha512❌ log 6/8❌ log 6/8❌ log 6/8imports
encoding❌ error❌ error❌ errorimports
encoding/ascii85imports
encoding/base32❌ log 22/23❌ log 21/23imports
encoding/base64❌ log 16/17imports
encoding/base64❌ log 16/17imports
encoding/binary❌ log 14/30❌ log 15/30❌ log 14/30imports
encoding/csvimports
encoding/gob❌ error❌ error❌ errorimports
encoding/heximports
encoding/json❌ log 2/24❌ log 2/24❌ log 13/84imports
errors❌ log 7/9❌ log 7/9❌ log 7/9imports
flag❌ error❌ error❌ errorimports
fmt❌ log 25/44❌ log 28/51❌ log 28/51imports
go/ast❌ error❌ error❌ errorimports
go/constant❌ error❌ error❌ errorimports
go/format❌ error❌ error❌ errorimports
go/importer❌ error❌ error❌ errorimports
go/printer❌ error❌ error❌ errorimports
go/scanner❌ error❌ error❌ errorimports
go/token❌ error❌ error❌ errorimports
go/token❌ error❌ error❌ errorimports
go/types❌ error❌ error❌ errorimports
hash❌ error❌ errorimports
hash/adler32imports
hash/adler32imports
hash/crc32❌ log 7/8❌ log 7/8❌ log 7/8imports
hash/crc64imports
hash/fnvimports
hash/html❌ error❌ error❌ errorimports
image❌ error❌ error❌ errorimports
image/colorimports
image/draw❌ error❌ error❌ errorimports
index/suffixarray❌ error❌ error❌ errorimports
io❌ log 5/8❌ log 36/53imports
io/fs❌ log 12/14❌ log 12/14❌ log 12/14imports
log❌ log 5/9❌ log 5/9❌ log 5/9imports
math❌ log 75/76imports
math/big❌ error❌ error❌ errorimports
math/bits❌ log 25/26imports
math/cmplx❌ log 15/23❌ log 15/24❌ errorimports
math/rand❌ log 11/17❌ log 12/17❌ errorimports
os❌ error❌ error❌ log 29/127imports
os/exec❌ error❌ error❌ errorimports
pathimports
path/filepath❌ log 15/28❌ log 15/28❌ log 17/39imports
reflect❌ error❌ error❌ errorimports
regexp❌ error❌ error❌ errorimports
regexp/syntaximports
runtime❌ error❌ error❌ errorimports
runtime/debug❌ error❌ error❌ errorimports
slices❌ log 2/43❌ log 2/43❌ log 2/43imports
sortimports
strconv❌ log 54/56imports
stringsimports
sync❌ error❌ error❌ errorimports
sync/atomic❌ error❌ error❌ errorimports
syscall❌ log 2/4❌ log 2/4❌ log 2/4imports
syscall/js❌ error❌ error❌ errorimports
testing/fstest❌ log 3/5❌ log 3/5❌ log 3/5imports
testing/iotest❌ log 12/15❌ log 12/15❌ log 12/15imports
testing/quick❌ error❌ error❌ errorimports
text/scannerimports
text/tabwriter❌ log 2/3❌ log 2/3❌ log 2/3imports
text/template❌ error❌ error❌ errorimports
text/template❌ error❌ error❌ errorimports
time❌ error❌ error❌ errorimports
unicodeimports
unicode/utf16imports
unicode/utf8imports
FAQ

Can library X be compiled?

Check online via:

Manual check:

You would need to check what imports and language features the library is using.

If it uses unsafe or generics, the library will not work.

If it uses networking or unsupported stdlibs it also will not work.

Does the compiler support Go as a Haxe target?

No and it's not within the scope of the project, however happy to knowledge transfer and support any Go target for Haxe.

Can high performance be achieved with the compiled code?

Yes! There is no inherent systemic issue with the compiled code having comparable speeds with normal Haxe code. The compiler does AST to AST translation so it is at the same level of abstraction for the Haxe compiler to be able to optimize the code in the same way as if it was handwritten.

The layer functions or interop files for the go2hx styled Haxe code to normal Haxe code does certantily have a performance penality, however for basics types it can be 0 because of Haxe's 0 cost abstractions, and in the case of structures or other cases where this is an allocation, it is possible to use the internal go2hx datatypes to not pay the penality (at the cost of ease of use).

This area is truthfully not very explored because of the priority of getting the compiler correct. If it is a painpoint for your usecase, we would love to hear more about it and improve it.

Why not use externs instead of compiling Go code into Haxe?

Because externs prevent multi target usage of the compiler and they need to be maintained and written. This project is meant to provide 100s of thousands of high quality tested Go libraries with no maintance and no need to write an abstraction level.

Cgo support?

Not available but planned and happily accepting contributions for it!

How does this compare to Gopherjs or Go wasm?

go2hx's design is built with Haxe devs in mind, therefore the goals align with Haxe dev advantages of the compiler, with that said go2hx does have some advantages already, smaller code generation, access to Haxe's compiler tooling such as dce and optimizations, and Haxe as a language being very portable, high level and statically typed.

What internals does stdlib use?

The compiler uses Haxe stdlib implmentations when interacting with the fileysytem and primitive math operations. In other cases the internals are transpiled into Haxe code and uses those.

Have issues and/or want to contribute?

github discord