From 34d6dfa3ca2b515af3482e327096ef54ca6b9381 Mon Sep 17 00:00:00 2001 From: aleksana Date: Tue, 24 Sep 2024 18:14:09 +0800 Subject: [PATCH] hello-go: init --- pkgs/by-name/he/hello-go/package.nix | 44 ++++++++++++++++++++++++++++ pkgs/by-name/he/hello-go/src/go.mod | 3 ++ pkgs/by-name/he/hello-go/src/main.go | 7 +++++ 3 files changed, 54 insertions(+) create mode 100644 pkgs/by-name/he/hello-go/package.nix create mode 100644 pkgs/by-name/he/hello-go/src/go.mod create mode 100644 pkgs/by-name/he/hello-go/src/main.go diff --git a/pkgs/by-name/he/hello-go/package.nix b/pkgs/by-name/he/hello-go/package.nix new file mode 100644 index 000000000000..e68c0b8c98fe --- /dev/null +++ b/pkgs/by-name/he/hello-go/package.nix @@ -0,0 +1,44 @@ +{ + lib, + buildGoModule, +}: + +buildGoModule { + name = "hello-go"; + + src = ./src; + + vendorHash = null; + + CGO_ENABLED = 0; + + # go installs binary into $out/bin/$GOOS_$GOARCH/hello-go in cross compilation + postInstall = '' + [[ -f "$out/bin/hello-go" ]] || ln -s ./''${GOOS}_''${GOARCH}/hello-go $out/bin/hello-go + ''; + + meta = { + description = "Simple program printing hello world in Go"; + longDescription = '' + hello-go is a simple program printing "Hello, world!" written in Go, + aiming at testing programs that involves analyzing executables or + emulating foreign architectures, without pulling in a heavy cross + toolchain. + + Specify target platform by setting GOOS and GOARCH: + + ```nix + hello-go.overrideAttrs { + GOOS = "linux"; + GOARCH = "arm64"; + } + ``` + + See https://pkg.go.dev/internal/platform#pkg-variables for a list + of available platforms. + ''; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ aleksana ]; + mainProgram = "hello-go"; + }; +} diff --git a/pkgs/by-name/he/hello-go/src/go.mod b/pkgs/by-name/he/hello-go/src/go.mod new file mode 100644 index 000000000000..4dc8dec9f4d0 --- /dev/null +++ b/pkgs/by-name/he/hello-go/src/go.mod @@ -0,0 +1,3 @@ +module hello-go + +go 1.22.7 diff --git a/pkgs/by-name/he/hello-go/src/main.go b/pkgs/by-name/he/hello-go/src/main.go new file mode 100644 index 000000000000..ef25884d828c --- /dev/null +++ b/pkgs/by-name/he/hello-go/src/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, world!") +}