ob-gore: literate Go run via the Gore REPL
I wrote and published my first Org Babel extension yuhu! It is super basic and just a hack really, but it works: https://github.com/ag91/ob-gore.
This enables you to write Go snippets in an Emacs Org Mode buffer so that you can evaluate them in a literate programming fashion through the Gore REPL. I have been looking into Go recently and I am writing down some notes on how things differ from Clojure. Firstly I tried out ob-go, but to get the output I needed to write the code like this:
#+begin_src go :imports '("fmt") list := []int{1,2,3} for i, value := range list { list[i] = value + 1 } fmt.Println(list) #+end_src
The Println
bit is necessary in this snippet, because ob-go produces
a Go file that gets evaluated and has to pass linting rules before
execution: list
must be used by the program.
I felt adding the Println
is an extra step than the simpler version
my ob-gore supports:
#+begin_src gore list := []int{1,2,3} for i, value := range list { list[i] = value + 1 } list #+end_src
Aside of the little time saved typing, the more interesting thing for somebody using Lisp everyday is that having a Gore REPL at hand allows me to test my ideas on the fly. I have even managed to show the output of evaluating a Go expression inline in the buffer (writing about that soon).
Anyway the little extension (which hacks builds over gorepl-mode) is
still a half-broken prototype, but I will improve it the more I
explore Go with a REPL (and at least is a starting point)!
Happy literate explorations!