diff options
author | mediocregopher <mediocregopher@gmail.com> | 2023-09-26 11:11:40 +0200 |
---|---|---|
committer | mediocregopher <mediocregopher@gmail.com> | 2023-09-26 11:11:40 +0200 |
commit | 95bae8af09e85f9d4400dcc70e70218f6cb8970b (patch) | |
tree | b139cafeb840a1c556fd7e9e0449cba80e43e11a /bin/go-playground | |
parent | dde4ecfeb0fdb28b0ee360e4846725226d044c3a (diff) |
Fix go-playground
Diffstat (limited to 'bin/go-playground')
-rwxr-xr-x | bin/go-playground | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/bin/go-playground b/bin/go-playground index 64633a9..b1b9661 100755 --- a/bin/go-playground +++ b/bin/go-playground @@ -1,5 +1,42 @@ #!/bin/sh -cd "$(mktemp -d)"; -go mod init local-playground; -echo 'package main\n\nimport (\n\t"fmt"\n)\n\nfunc main() {\n\tfmt.Println("aloha")\n}\n' > main.go; -$EDITOR main.go; + +set -e -x + +cd "$(mktemp -d)" + +cat >main.go <<EOF +package main + +import ( + "fmt" +) + +func main() { + fmt.Println("aloha") +} +EOF + +cat >shell.nix <<EOF +let + pkgsVersion = "22.11"; + pkgsSrc = fetchTarball { + name = "nixpkgs-\${pkgsVersion}"; + url = "https://github.com/NixOS/nixpkgs/archive/ce20e9ebe1903ea2ba1ab006ec63093020c761cb.tar.gz"; + sha256 = "sha256-eFNm2h6fNbgD7ZpO4MHikCB5pSnCJ7DTmwPisjetmwc="; + }; + pkgs = (import pkgsSrc) {}; +in + pkgs.mkShell { + buildInputs = [ + pkgs.go + pkgs.golangci-lint + ]; + + shellHook = '' + go mod init local-playground + $EDITOR main.go + ''; + } +EOF + +nix-shell -v |