Skip to content

milindmadhukar/go-piston

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Piston!

This is a Go wrapper for working with the Piston API.

It supports both the endpoints, namely runtimes and execute, mentioned here.

💻 Installation

To install the library simply open a terminal and type:

go get github.com/milindmadhukar/go-piston

️️🛠️ Tools Used

This project was written purely in Golang for Golang.
The module helps with the usage of the Piston API.

🏁 Basic Setup:

package main

import (
	"fmt"
	"log"

	piston "github.com/milindmadhukar/go-piston"
)

func main() {
	client := piston.CreateDefaultClient()
	execution, err := client.Execute("python", "", // Passing language. Since no version is specified, it uses the latest supported version.
		[]piston.Code{
			{Content: "inp = input()\nprint(inp[::-1])"},
		}, // Passing Code.
		piston.Stdin("hello world"), // Passing input as "hello world".
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(execution.GetOutput())
}

Output

dlrow olleh

🧿 Extras

If you face any difficulties contact me here.

Thats it, have fun ✚✖