blob: 81211ee452a135d282f4e7b261080d5f09a02b47 (
plain)
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
51
52
53
54
55
|
#
# Go
#
# Go is an open source programming language that makes it easy
# to build efficient software.
# Link: https://golang.org/
function __sf_section_golang -d "Display the current go version if you're inside GOPATH"
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
__sf_util_set_default SPACEFISH_GOLANG_SHOW true
__sf_util_set_default SPACEFISH_GOLANG_PREFIX $SPACEFISH_PROMPT_DEFAULT_PREFIX
__sf_util_set_default SPACEFISH_GOLANG_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX
__sf_util_set_default SPACEFISH_GOLANG_SYMBOL "🐹 "
__sf_util_set_default SPACEFISH_GOLANG_COLOR cyan
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
# Show the current version of Golang
[ $SPACEFISH_GOLANG_SHOW = false ]; and return
# Ensure the go command is available
type -q go; or return
if not test -f go.mod \
-o -d Godeps \
-o -f glide.yaml \
-o (count *.go) -gt 0 \
-o -f Gopkg.yml \
-o -f Gopkg.lock \
-o ([ (count $GOPATH) -gt 0 ]; and string match $GOPATH $PWD)
return
end
set -l go_version (go version | string split ' ')
# Go version is either the commit hash and date (devel +5efe9a8f11 Web Jan 9 07:21:16 2019 +0000)
# at the time of the build or a release tag (go1.11.4)
# https://github.com/matchai/spacefish/issues/137
if test (string match 'devel*' $go_version[3])
set go_version $go_version[3]":"(string sub -s 2 $go_version[4])
else
set go_version "v"(string sub -s 3 $go_version[3])
end
__sf_lib_section \
$SPACEFISH_GOLANG_COLOR \
$SPACEFISH_GOLANG_PREFIX \
"$SPACEFISH_GOLANG_SYMBOL""$go_version" \
$SPACEFISH_GOLANG_SUFFIX
end
|