-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgo.tengo
More file actions
54 lines (50 loc) · 1.76 KB
/
go.tengo
File metadata and controls
54 lines (50 loc) · 1.76 KB
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
os := import("os")
fmt := import("fmt")
text := import("text")
nami := import("nami")
json := import("json")
b := nami.sh1("curl", "-L", "https://go.dev/dl/?mode=json")
if is_error(b) {
fmt.println(b)
os.exit(1)
}
v := json.decode(b)[0].version[2:]
err := nami.write_file(nami.cache_dir+"/version", v)
if is_error(err) {
fmt.println(err)
os.exit(1)
}
if nami.os != "linux" && nami.os != "darwin" && nami.os != "windows" {
fmt.println("This package does not support your OS or Arch now. PR welcome: https://github.com/txthinking/nami/blob/master/package")
os.exit(1)
}
if nami.os != "windows" {
err := nami.sh("curl", "-L", "--progress-bar", "https://go.dev/dl/go"+v+"."+nami.os+"-"+nami.arch+".tar.gz", "-o", "/tmp/_.tgz")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", "/tmp/_")
nami.sh("mkdir", "/tmp/_")
nami.sh("tar", "zxvf", "/tmp/_.tgz", "-C", "/tmp/_")
nami.sh("mv", "/tmp/_/go", nami.cache_dir+"/go")
nami.write_file(nami.cache_dir+"/links", "go/bin/go\n")
nami.append_file(nami.cache_dir+"/links", "go/bin/gofmt\n")
}
if nami.os == "windows" {
if err := nami.sh("which", "7z"); is_error(err){
fmt.println("Please install 7z first: $ nami install 7z")
os.exit(1)
}
err := nami.sh("curl", "-L", "--progress-bar", "https://go.dev/dl/go"+v+"."+nami.os+"-"+nami.arch+".zip", "-o", "/tmp/_.zip")
if is_error(err) {
fmt.println(err)
os.exit(1)
}
nami.sh("rm", "-rf", "/tmp/_")
nami.sh("mkdir", "/tmp/_")
nami.sh("7z", "x", "/tmp/_.zip", "-o/tmp/_")
nami.sh("mv", "/tmp/_/go", nami.cache_dir+"/go")
nami.write_file(nami.cache_dir+"/links", "go/bin/go.exe\n")
nami.append_file(nami.cache_dir+"/links", "go/bin/gofmt.exe\n")
}