Git Product home page Git Product logo

ranna-go

ranna-go is a Golang client implementation for the code execution sandbox ranna.

Please note: ranna already provides a Golang client implementation here. If this is enough for you, go for it. With this library I aim at providing a generic client for ranna plus the according other microservices (snippets).

Usage

Download the library:

go get github.com/lus/ranna-go

Code execution

package main

import "github.com/lus/ranna-go/ranna"

func main() {
    client := ranna.NewClient("https://public.ranna.zekro.de")
    
    // Retrieve all registered language specifications
    specs, err := client.Specs()
    if err != nil {
        panic(err)
    }
    // specs now contains a map of language specifications

    // Execute Go code
    code := `
        package main

        import "fmt"

        func main() {
            fmt.Println("Hello, ranna!")
        }
    `
    request := &ranna.ExecutionRequest{
        Language:    "go",
        Code:        code,
        Arguments:   []string{},
        Environment: map[string]string{},
    }
    result, err := client.Execute(request)
    if err != nil {
        panic(err)
    }
    // result contains stdout, stderr and the execution duration
}

Snippets

package main

import "github.com/lus/ranna-go/snippets"

func main() {
    client := snippets.NewClient("https://snippets.ranna.zekro.de")

    // Create a Go code sippet
    code := `
        package main

        import "fmt"

        func main() {
            fmt.Println("Hello, ranna!")
        }
    `
    snippet := &snippets.Snippet{
        Language: "go",
        Code:     code,
    }
    created, err := client.Create(snippet)
    if err != nil {
        panic(err)
    }
    // created contains the created snippet

    // Retrieve a code snippet
    retrieved, err := client.Snippet("snippet")
    if err != nil {
        panic(err)
    }
    // retrieved contains the retrieved snippet
}

ranna's Projects

cli icon cli

CLI tool to access the ranna API from your terminal.

gatekeeper icon gatekeeper

Simple basic token authorization microservice designed to be combined with the ForwardAuth middleware of traefik.

gotip icon gotip

Unofficial Gotip toolchain Docker image.

infrastructure icon infrastructure

A collection of configurations and documentation for the ranna stack.

kyasshu icon kyasshu

A little response caching microservice to reduce load of repeated requests.

language-api icon language-api

A simple static API to supply GitHub's linguist language information as JSON API.

ranna icon ranna

A code execution microservice based on Docker containers.

ranna-go icon ranna-go

A client implementation for ranna-go/ranna written in Golang

ranna-ts icon ranna-ts

TypeScript client wrapper for the ranna API.

snippets icon snippets

Simple microservice to store code snippets in a database.

webapp icon webapp

Web app to execute and share your code directly in the browser.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.