add piston nix pkg for go

This commit is contained in:
Dan Vargas 2022-02-16 09:10:46 -07:00
parent 226eca1fb9
commit bc2036486c
7 changed files with 39 additions and 26 deletions

View File

@ -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

View File

@ -1,2 +0,0 @@
export PATH=$PWD/go/bin:$PATH
export GOPATH=$PWD/gopath

View File

@ -1,5 +0,0 @@
{
"language": "go",
"version": "1.16.2",
"aliases": ["go", "golang"]
}

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
mv $1 $1.go
#filename=$1.go
filename=*.go
shift
GOCACHE=$PWD go run $filename "$@"

View File

@ -1,7 +0,0 @@
package main
import "fmt"
func main() {
fmt.Println("OK")
}

View File

@ -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;
}

38
runtimes/go.nix Normal file
View File

@ -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";
})
];
}