Cljs2go是ClojureScript转换为Go的编译器。
ClojureScript转换到Go,不是分支出来,而是直接覆盖到ClojureScript上。Go是从cljs.go.compiler上发行出去,而cljs.go.compiler是cljs.compiler的一个补丁版本。在运行时,会提供简单的JS兼容以避免接触 cljs.core,这些js和goog包不打算对用户开放使用。
一旦编译器开始工作,该计划将提供第二个猴子补丁(mokeypatch),这回是提供Java依赖,像java.io.File和其他Clojure副本,clojure.java.io。此补丁可以将编译器本身编译成Go。这既不会改变运行时编译程序的特点,也不会引入eval,它只是充分利用了Go来建造管道。
示例代码:
# Cloe ad build the Go packages:$ go get github.com/hraberg/cljs2go# The repo itself lives uder src by covetio:$ cd $GOPATH/src/github.com/hraberg/cljs2go# go test, for Go tests checked ito git, both geerated ad hadwritte oes:$ go test -v ./...# To re-geerate the tests from ClojureScript (this might dirty the repo):$ lei test# (This also geerates ad rus some tests uder target/geerated which are't checked i.)# To re-geerate the Go for ClojureScript itself:$ go geerate









评论