feat: support install go
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import subprocess
|
||||||
|
import urllib.request
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
@@ -34,6 +36,7 @@ class Installer(Base):
|
|||||||
"z": self.install_z,
|
"z": self.install_z,
|
||||||
"git": self.install_git,
|
"git": self.install_git,
|
||||||
"packer": self.install_packer,
|
"packer": self.install_packer,
|
||||||
|
"go": self.install_go,
|
||||||
}
|
}
|
||||||
if val in install_map:
|
if val in install_map:
|
||||||
install_map.get(val)()
|
install_map.get(val)()
|
||||||
@@ -64,6 +67,20 @@ class Installer(Base):
|
|||||||
os.system("git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim")
|
os.system("git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim")
|
||||||
else:
|
else:
|
||||||
print("packer already installed")
|
print("packer already installed")
|
||||||
|
def install_go(self):
|
||||||
|
version = urllib.request.urlopen("https://go.dev/VERSION?m=text").read()
|
||||||
|
if self.cmd_exist("go"):
|
||||||
|
run("go version")
|
||||||
|
cwd = os.getcwd()
|
||||||
|
os.chdir("/usr/local/")
|
||||||
|
name = "%s.darwin-amd64.tar.gz"%(version.decode())
|
||||||
|
u="https://dl.google.com/go/"+name
|
||||||
|
run("sudo mv go go_old")
|
||||||
|
run("sudo rm "+name)
|
||||||
|
run("sudo wget "+u)
|
||||||
|
run("sudo tar zxf "+name)
|
||||||
|
run("go version")
|
||||||
|
os.chdir(cwd)
|
||||||
class Base(object):
|
class Base(object):
|
||||||
def cmd_exist(self, name):
|
def cmd_exist(self, name):
|
||||||
from shutil import which
|
from shutil import which
|
||||||
@@ -78,6 +95,9 @@ class Base(object):
|
|||||||
os.system("mv %s %s.bak"%(name,name))
|
os.system("mv %s %s.bak"%(name,name))
|
||||||
os.system("ln -s %s %s"%(target,name))
|
os.system("ln -s %s %s"%(target,name))
|
||||||
|
|
||||||
|
def run(cmd:str):
|
||||||
|
subprocess.run(cmd.split())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user