~ruther/guix-local

ref: e9c4dc10bfaba77e2619cb38acc5c4a9d15b284a guix-local/gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch -rw-r--r-- 1.7 KiB
e9c4dc10 — Andreas Enge gnu: Remove python-misaka. 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
If built locally, dicedb works for as long as the build cache in the tmp
directory exists - it looks for a file called VERSION in the project root.
Once cleared, or in the case of downloading from substitute server, the
location of the VERSION file is invalid. Removing this code and instead
providing them through the flag resolves this issue.

diff --git a/config/config.go b/config/config.go
index b358813..c408096 100644
--- a/config/config.go
+++ b/config/config.go
@@ -9,8 +9,6 @@ import (
 	"os"
 	"path/filepath"
 	"reflect"
-	"runtime"
-	"strings"
 
 	"github.com/spf13/pflag"
 	"github.com/spf13/viper"
@@ -20,30 +18,6 @@ var (
 	DiceDBVersion = "-"
 )
 
-// init initializes the DiceDBVersion variable by reading the
-// VERSION file from the project root.
-// This function runs automatically when the package is imported.
-func init() {
-	// Get the absolute path of the current file (config.go)
-	// using runtime reflection
-	_, currentFile, _, _ := runtime.Caller(0) //nolint:dogsled
-
-	// Navigate up two directories from config.go to reach the project root
-	// (config.go is in the config/ directory, so we need to go up twice)
-	projectRoot := filepath.Dir(filepath.Dir(currentFile))
-
-	// Read the VERSION file from the project root
-	// This approach works regardless of where the program is executed from
-	version, err := os.ReadFile(filepath.Join(projectRoot, "VERSION"))
-	if err != nil {
-		slog.Error("could not read the version file", slog.String("error", err.Error()))
-		os.Exit(1)
-	}
-
-	// Store the version string in the package-level DiceDBVersion variable
-	DiceDBVersion = strings.TrimSpace(string(version))
-}
-
 var Config *DiceDBConfig
 
 type DiceDBConfig struct {