x
This commit is contained in:
+29
-27
@@ -36,32 +36,34 @@ var languages = []Language{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
for _, item := range languages {
|
go func() {
|
||||||
if !(item.Os == runtime.GOOS && item.Arch == runtime.GOARCH) {
|
for _, item := range languages {
|
||||||
continue
|
if !(item.Os == runtime.GOOS && item.Arch == runtime.GOARCH) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
func() {
|
||||||
|
dir := utils.ExecPath + "/language/" + item.Name
|
||||||
|
data, _ := os.ReadFile(dir + "/version")
|
||||||
|
if string(data) == item.Version {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
os.MkdirAll(utils.ExecPath+"/language/"+item.Name, 0755)
|
||||||
|
resp, err := http.Get(item.Links[0])
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
f, err := os.OpenFile(dir+"/"+item.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
_, err = io.Copy(f, resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
os.WriteFile(dir+"/version", []byte(item.Version), 0755)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
func() {
|
}()
|
||||||
dir := utils.ExecPath + "/language/" + item.Name
|
|
||||||
data, _ := os.ReadFile(dir + "/version")
|
|
||||||
if string(data) == item.Version {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
os.MkdirAll(utils.ExecPath+"/language/"+item.Name, 0755)
|
|
||||||
resp, err := http.Get(item.Links[0])
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
f, err := os.OpenFile(dir+"/"+item.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
_, err = io.Copy(f, resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
os.WriteFile(dir+"/version", []byte(item.Version), 0755)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func initNodePlugins() {
|
|||||||
plugins := []string{root}
|
plugins := []string{root}
|
||||||
os.Mkdir(root, 0755)
|
os.Mkdir(root, 0755)
|
||||||
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||||
if !strings.HasPrefix(path, "/Users/a1-6/Code/sillyplus/plugins/") {
|
if !strings.HasPrefix(path, utils.ExecPath+"/plugins/") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
files := strings.Split(strings.Replace(path, root+"/", "", 1), "/")
|
files := strings.Split(strings.Replace(path, root+"/", "", 1), "/")
|
||||||
|
|||||||
Reference in New Issue
Block a user