From bc2036486c3dab726234a38a722b1b719c41e925 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Wed, 16 Feb 2022 09:10:46 -0700 Subject: [PATCH] add piston nix pkg for go --- packages/go/1.16.2/build.sh | 5 ----- packages/go/1.16.2/environment | 2 -- packages/go/1.16.2/metadata.json | 5 ----- packages/go/1.16.2/run | 7 ------ packages/go/1.16.2/test.go | 7 ------ runtimes/default.nix | 1 + runtimes/go.nix | 38 ++++++++++++++++++++++++++++++++ 7 files changed, 39 insertions(+), 26 deletions(-) delete mode 100755 packages/go/1.16.2/build.sh delete mode 100644 packages/go/1.16.2/environment delete mode 100644 packages/go/1.16.2/metadata.json delete mode 100644 packages/go/1.16.2/run delete mode 100644 packages/go/1.16.2/test.go create mode 100644 runtimes/go.nix diff --git a/packages/go/1.16.2/build.sh b/packages/go/1.16.2/build.sh deleted file mode 100755 index 5cf70f9..0000000 --- a/packages/go/1.16.2/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -curl -LO https://golang.org/dl/go1.16.2.linux-amd64.tar.gz -tar -xzf go1.16.2.linux-amd64.tar.gz -rm go1.16.2.linux-amd64.tar.gz - diff --git a/packages/go/1.16.2/environment b/packages/go/1.16.2/environment deleted file mode 100644 index 88299c1..0000000 --- a/packages/go/1.16.2/environment +++ /dev/null @@ -1,2 +0,0 @@ -export PATH=$PWD/go/bin:$PATH -export GOPATH=$PWD/gopath diff --git a/packages/go/1.16.2/metadata.json b/packages/go/1.16.2/metadata.json deleted file mode 100644 index 0144808..0000000 --- a/packages/go/1.16.2/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "go", - "version": "1.16.2", - "aliases": ["go", "golang"] -} diff --git a/packages/go/1.16.2/run b/packages/go/1.16.2/run deleted file mode 100644 index 65c9a4f..0000000 --- a/packages/go/1.16.2/run +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -mv $1 $1.go -#filename=$1.go -filename=*.go -shift -GOCACHE=$PWD go run $filename "$@" diff --git a/packages/go/1.16.2/test.go b/packages/go/1.16.2/test.go deleted file mode 100644 index c06f485..0000000 --- a/packages/go/1.16.2/test.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "fmt" - -func main() { - fmt.Println("OK") -} diff --git a/runtimes/default.nix b/runtimes/default.nix index cad9dd2..807d46d 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -44,4 +44,5 @@ args: { "iverilog" = import ./iverilog.nix args; "ghc-haskell" = import ./ghc-haskell.nix args; "groovy" = import ./groovy.nix args; + "go" = import ./go.nix args; } diff --git a/runtimes/go.nix b/runtimes/go.nix new file mode 100644 index 0000000..d4b12e3 --- /dev/null +++ b/runtimes/go.nix @@ -0,0 +1,38 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.go; +in piston.mkRuntime { + language = "go"; + version = pkg.version; + + aliases = [ + "golang" + ]; + + run = '' + mv $1 $1.go + filename=*.go + shift + GOCACHE=$PWD ${pkg}/bin/go run $filename "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.go" = '' + package main + + import "fmt" + + func main() { + fmt.Println("OK") + } + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.go"; + }) + ]; +} \ No newline at end of file