File: version.go

package info (click to toggle)
gobuster 3.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: makefile: 7
file content (46 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
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
package libgobuster

import (
	"fmt"
	"runtime/debug"
	"strconv"
)

const (
	// VERSION contains the current gobuster version
	VERSION = "3.8"
)

func GetVersion() string {
	modified := false
	revision := ""
	time := ""
	if info, ok := debug.ReadBuildInfo(); ok {
		for _, setting := range info.Settings {
			if setting.Key == "vcs.revision" {
				revision = setting.Value
			}
			if setting.Key == "vcs.time" {
				time = setting.Value
			}
			if setting.Key == "vcs.modified" {
				if mod, err := strconv.ParseBool(setting.Value); err == nil {
					modified = mod
				}
			}
		}
	}
	version := VERSION
	if revision != "" {
		version = fmt.Sprintf("%s Revision %s", version, revision)
	}

	if modified {
		version = fmt.Sprintf("%s [DIRTY]", version)
	}
	if time != "" {
		version = fmt.Sprintf("%s from %s", version, time)
	}

	return version
}