golds: init at 0.7.1

Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
Co-authored-by: Kenichi Kamiya <kachick1@gmail.com>
This commit is contained in:
phanirithvij
2024-11-23 08:52:29 +05:30
parent 5627b82bfb
commit daec649173
2 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
diff --git a/internal/server/info_module.go b/internal/server/info_module.go
index d2513bd..ad2921e 100644
--- a/internal/server/info_module.go
+++ b/internal/server/info_module.go
@@ -8,6 +8,7 @@ import (
"io/ioutil"
"log"
"os"
+ "os/exec"
"path/filepath"
"regexp"
"strings"
@@ -756,7 +757,11 @@ func findGoToolchainVersionFromGoRoot(goroot string) (string, error) {
versionData, err = ioutil.ReadFile(filepath.Join(goroot, "VERSION.cache"))
}
if err != nil {
- return "", fmt.Errorf("failed to get Go toolchain version in GOROOT (%s)", goroot)
+ cmd := exec.Command("go", "env", "GOVERSION")
+ versionData, err = cmd.Output()
+ if err != nil {
+ return "", fmt.Errorf("failed to get Go toolchain version in GOROOT (%s)", goroot)
+ }
}
matches := findGoVersionRegexp.FindSubmatch(versionData)
if len(matches) >= 1 {

View File

@@ -0,0 +1,42 @@
{
lib,
buildGoModule,
fetchFromGitHub,
testers,
golds, # self
}:
buildGoModule rec {
pname = "golds";
version = "0.7.1";
src = fetchFromGitHub {
owner = "go101";
repo = "golds";
tag = "v${version}";
hash = "sha256-6YkyKJtSAFFYidMlZXSjNpjyIIaTlibg/QMMin/NbU0=";
};
# nixpkgs is not using the go distpack archive and missing a VERSION file in the source
# but we can use go env to get the same information
# https://github.com/NixOS/nixpkgs/pull/358316#discussion_r1855322027
patches = [ ./info_module-gover.patch ];
vendorHash = "sha256-omjHRZB/4VzPhc6RrFY11s6BRD69+Y4RRZ2XdeKbZf0=";
ldflags = [ "-s" ];
passthru.tests.version = testers.testVersion {
package = golds;
version = "v${version}";
};
meta = {
description = "Experimental Go local docs server/generator and code reader implemented with some fresh ideas";
homepage = "https://github.com/go101/golds";
license = lib.licenses.mit;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ phanirithvij ];
mainProgram = "golds";
};
}