Skip to content

-play: add go.godbolt.org as exec backend #13

@dolmen

Description

@dolmen

https://go.godbolt.org/

The Compiler Explorer has a REST API for compile+execution:
https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/API.md#post-apicompilercompiler-idcompile---perform-a-compilation

To list Go compilers:
https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/API.md#get-apicompilerslanguage-id---return-a-list-of-compilers-with-matching-language

List compilers

$ curl -s https://go.godbolt.org/api/compilers/go
$ curl -s -H 'Accept: application/json' 'https://go.godbolt.org/api/compilers/go?fields=all' | jq .
$ curl -s https://go.godbolt.org/api/compilers/go | grep '^[a-z0-9_]*gltip '

Run

$ goeval -E 'fmt.Println("Hello")' | jq -s -R '{"source":.,"options":{"compilerOptions":{"skipAsm":true},"filters":{"execute":true,}},"allowStoreCodeDebug":false,"bypassCache":2}' | curl -s -XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '@-' https://go.godbolt.org/api/compiler/gltip/compile | jq .

$ goeval -E 'fmt.Println(time.Now())' | jq -s -R '{"source":.,"options":{"compilerOptions":{"skipAsm":true,"executorRequest":true},"filters":{"execute":true}},"allowStoreCodeDebug":false,"bypassCache":2}' | curl -s -XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' --data-binary '@-' https://go.godbolt.org/api/compiler/gltip/compile | jq -r '(.stdout[],.stderr[]) | .text'
2025-06-16 09:24:30.575222479 +0000 UTC m=+0.000016946

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions