summaryrefslogtreecommitdiffstats
path: root/src/go/pkg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 08:15:35 +0000
commitf09848204fa5283d21ea43e262ee41aa578e1808 (patch)
treec62385d7adf209fa6a798635954d887f718fb3fb /src/go/pkg
parentReleasing debian version 1.46.3-2. (diff)
downloadnetdata-f09848204fa5283d21ea43e262ee41aa578e1808.tar.xz
netdata-f09848204fa5283d21ea43e262ee41aa578e1808.zip
Merging upstream version 1.47.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/pkg')
-rw-r--r--src/go/pkg/buildinfo/version.go6
-rw-r--r--src/go/pkg/executable/executable.go43
2 files changed, 49 insertions, 0 deletions
diff --git a/src/go/pkg/buildinfo/version.go b/src/go/pkg/buildinfo/version.go
new file mode 100644
index 000000000..55977a592
--- /dev/null
+++ b/src/go/pkg/buildinfo/version.go
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package buildinfo
+
+// Version stores the agent's version number. It's set during the build process using build flags.
+var Version = "v0.0.0"
diff --git a/src/go/pkg/executable/executable.go b/src/go/pkg/executable/executable.go
new file mode 100644
index 000000000..3f4e9e0de
--- /dev/null
+++ b/src/go/pkg/executable/executable.go
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package executable
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+var (
+ Name string
+ Directory string
+)
+
+func init() {
+ path, err := os.Executable()
+ if err != nil || path == "" {
+ return
+ }
+
+ _, Name = filepath.Split(path)
+ Name = strings.TrimSuffix(Name, ".plugin")
+
+ if strings.HasSuffix(Name, ".test") {
+ Name = "test"
+ }
+
+ fi, err := os.Lstat(path)
+ if err != nil {
+ return
+ }
+
+ if fi.Mode()&os.ModeSymlink != 0 {
+ realPath, err := filepath.EvalSymlinks(path)
+ if err != nil {
+ return
+ }
+ Directory = filepath.Dir(realPath)
+ } else {
+ Directory = filepath.Dir(path)
+ }
+}