embed dependencies

This commit is contained in:
josc146
2023-05-29 09:39:16 +08:00
parent d66c30698c
commit 6fc5a335fb
8 changed files with 52 additions and 89 deletions

View File

@@ -3,8 +3,10 @@ package backend_golang
import (
"archive/zip"
"bufio"
"embed"
"errors"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
@@ -41,6 +43,34 @@ func Cmd(args ...string) (string, error) {
}
}
func CopyEmbed(efs embed.FS) error {
err := fs.WalkDir(efs, ".", func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
}
if err != nil {
return err
}
content, err := efs.ReadFile(path)
if err != nil {
return err
}
err = os.MkdirAll(path[:strings.LastIndex(path, "/")], 0755)
if err != nil {
return err
}
err = os.WriteFile(path, content, 0644)
if err != nil {
return err
}
return nil
})
return err
}
func GetPython() (string, error) {
switch platform := runtime.GOOS; platform {
case "windows":