Home

gomodinit @main - refs - log -
-
https://git.jolheiser.com/gomodinit.git
go mod init
tree log patch
fix: clean override Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQNwnIejXSTnEFcTiRnuOfiGgJe7TwDROTRG0PwSRAVwQJVNuRXHTZPoHwsJpgKxrhj /nBhwkFCgQsC18dWmUJAU= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
4 months ago
3 changed files, 39 additions(+), 35 deletions(-)
M flake.lockflake.lock
diff --git a/flake.lock b/flake.lock
index e8408a257429bfbc70205e5e649685f7138b5a0b..f69c4ce8c437e1c377e1ac4af99687caa81752ec 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,15 +2,16 @@ {
   "nodes": {
     "nixpkgs": {
       "locked": {
-        "lastModified": 1703206931,
-        "narHash": "sha256-GHJl3HHdH4jWjRVBuyDRIaUoNNMTuVbw0i9+EaYzcBU=",
+        "lastModified": 1733935885,
+        "narHash": "sha256-xyiHLs6KJ1fxeGmcCxKjJE4yJknVJxbC8Y/ZRYyC8WE=",
         "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "bfbfb344598544058481e254b9f0f174d05b5e6a",
+        "rev": "5a48e3c2e435e95103d56590188cfed7b70e108c",
         "type": "github"
       },
       "original": {
         "owner": "nixos",
+        "ref": "nixpkgs-unstable",
         "repo": "nixpkgs",
         "type": "github"
       }
M flake.nixflake.nix
diff --git a/flake.nix b/flake.nix
index a7c7508c716fabe261ce3c719c7ad302630a45c4..00d45c1c0cb539f6ab368926d62f338b26f0022e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,39 +1,41 @@
 {
   description = "go mod init";
-
-  inputs.nixpkgs.url = "github:nixos/nixpkgs";
+  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
 
-  outputs = {
-    self,
-    nixpkgs,
-  }: let
-    system = "x86_64-linux";
-    pkgs = nixpkgs.legacyPackages.${system};
-  in {
-    packages.${system}.default = pkgs.buildGoModule rec {
-      pname = "gomodinit";
-      version = self.rev or "dev";
-      src = ./.;
-      vendorHash = nixpkgs.lib.fileContents ./go.mod.sri;
-      ldflags = [
-        "-s"
-        "-w"
-        "-X=main.Version=${version}"
-      ];
+  outputs =
+    {
+      self,
+      nixpkgs,
+    }:
+    let
+      system = "x86_64-linux";
+      pkgs = nixpkgs.legacyPackages.${system};
+    in
+    {
+      packages.${system}.default = pkgs.buildGoModule rec {
+        pname = "gomodinit";
+        version = self.rev or "dev";
+        src = ./.;
+        vendorHash = nixpkgs.lib.fileContents ./go.mod.sri;
+        ldflags = [
+          "-s"
+          "-w"
+          "-X=main.Version=${version}"
+        ];
 
-      meta = with pkgs.lib; {
-        description = "go mod init";
-        homepage = "https://git.jolheiser.com/gomodinit";
-        maintainers = with maintainers; [jolheiser];
-        mainProgram = "gomodinit";
+        meta = with pkgs.lib; {
+          description = "go mod init";
+          homepage = "https://git.jolheiser.com/gomodinit";
+          maintainers = with maintainers; [ jolheiser ];
+          mainProgram = "gomodinit";
+        };
       };
-    };
 
-    devShells.${system}.default = pkgs.mkShell {
-      nativeBuildInputs = with pkgs; [
-        go
-        gopls
-      ];
+      devShells.${system}.default = pkgs.mkShell {
+        nativeBuildInputs = with pkgs; [
+          go
+          gopls
+        ];
+      };
     };
-  };
 }
M main.gomain.go
diff --git a/main.go b/main.go
index 6b688ad153d627b197eff14fb1c5d6ebb9f4cd5a..7d390454567c4aff67019aa85f5ccf8fd53d5b28 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	"bytes"
 	"errors"
 	"flag"
 	"fmt"
@@ -73,5 +74,5 @@ 	}
 
 	parts := strings.SplitN(name, "/", 2)
 
-	return fmt.Sprintf("%s/%s", override, parts[1]), nil
+	return fmt.Sprintf("%s/%s", bytes.TrimSpace(override), parts[1]), nil
 }