— a lightweight dynamic language for the JVM.

back to the front page

 Golo 0-preview9 Devoxx Edition

Golo 0-preview is there just in time for the awesome Devoxx 2013 conference!

If you are attending Devoxx next week, do not miss our Golo Tools in Action session Tuesday 18:05 - 18:35 Room 9.

What’s new?

Highlight of this release: class adapters

Sometimes you play with a third-party API, and this third-party API wants you to pass some object that is an instance of some interface or class.

We now provide you with an API to generate adapter classes at runtime.

The Spark micro web framework is a great example, as it expects HTTP request handlers to subclass spark.Route at some point.

Here is how this can be done in Golo:

module sparky

import spark
import spark.Spark

function main = |args| {

  # Configuration
  let adaptation = map[
    ["extends", "spark.Route"],
    ["implements", map[
      ["handle", |this, request, response| {
        return args: get(0)

  # Adapter "factory"
  let fabric = AdapterFabric()
  let routeMaker = fabric: maker(adaptation)

  # Make Spark happy
  get(routeMaker: newInstance("/"))

The API allows for more fancy things, including overriding methods and doing some form of proxying.

The following snippet is an example where we proxy a list to replicate all add method calls into another list called carbonCopy:

let carbonCopy = list[]
let conf = map[
  ["extends", "java.util.ArrayList"],
  ["overrides", map[
    ["*", |super, name, args| {
      if name == "add" {
        if args: length() == 2 {
          carbonCopy: add(args: get(1))
        } else {
          carbonCopy: add(args: get(1), args: get(2))
      return super: spread(args)
let list = AdapterFabric(): maker(conf): newInstance()
list: add("bar")
list: add(0, "foo")
list: add("baz")

# Guess what is inside carbonCopy...

Classpath flag

The golo and run subcommands of the golo command-line tool now support a classpath flag that adds both jars and folders to the classpath.

The “nice” thing is that it does not use a separator based syntax, hence you can do:

golo golo --classpath lib/*.jar /some/path /tmp/all/*.jar --files main.golo

Classloader improvements

Thanks to the feedback from Julien Viet, we improved the way Golo deals with classloaders. More specifically, it works fine in container-style environments such as Java application servers.


Our Golo Developer Advocate Philippe contributed some new augmentations: count and exists on lists, maps, tuples, vectors and sets.

Reading passwords from the standard console input (readPassword) can now be made in a secure fashion.

…and of course we have small fixes there and there.

Until next time…

comments powered by Disqus

Copyright © 2012 – 2018 INSA Lyon, CITI Laboratory and contributors.

Privacy Policy | Terms of Use | Copyright Agent | Eclipse Public License | Legal Resources