144 lines
1.8 KiB
Markdown
144 lines
1.8 KiB
Markdown
# Guía de Go (Golang)
|
|
|
|
Go es un lenguaje de programación compilado, rápido y muy útil para aplicaciones backend, CLI y herramientas de sistema.
|
|
|
|
## 1. Instalar Go
|
|
|
|
### Windows
|
|
|
|
Descarga el instalador oficial desde:
|
|
|
|
```text
|
|
https://go.dev/dl/
|
|
```
|
|
|
|
### macOS
|
|
|
|
Con Homebrew:
|
|
|
|
```bash
|
|
brew install go
|
|
go version
|
|
```
|
|
|
|
También puedes añadir el PATH:
|
|
|
|
```bash
|
|
echo 'export PATH=$PATH:$HOME/go/bin' >> ~/.zshrc
|
|
source ~/.zshrc
|
|
```
|
|
|
|
### Linux
|
|
|
|
Ubuntu/Debian:
|
|
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install golang-go
|
|
```
|
|
|
|
Instalación manual:
|
|
|
|
```bash
|
|
sudo rm -rf /usr/local/go
|
|
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
|
|
sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
|
|
```
|
|
|
|
Añadir al PATH:
|
|
|
|
```bash
|
|
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
|
|
source ~/.profile
|
|
```
|
|
|
|
---
|
|
|
|
## 2. Verificar instalación
|
|
|
|
```bash
|
|
go version
|
|
```
|
|
|
|
---
|
|
|
|
## 3. Crear un proyecto Go
|
|
|
|
```bash
|
|
mkdir mi-app-gui
|
|
cd mi-app-gui
|
|
go mod init mi-app-gui
|
|
```
|
|
|
|
---
|
|
|
|
## 4. Instalar Fyne
|
|
|
|
```bash
|
|
go get fyne.io/fyne/v2@latest
|
|
```
|
|
|
|
---
|
|
|
|
## 5. Ejemplo básico con Fyne
|
|
|
|
Crea `main.go`:
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fyne.io/fyne/v2/app"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
|
|
func main() {
|
|
miApp := app.New()
|
|
miVentana := miApp.NewWindow("Fyne Multiplataforma")
|
|
miVentana.SetContent(widget.NewLabel("¡Hola Mundo desde Fyne!"))
|
|
miVentana.ShowAndRun()
|
|
}
|
|
```
|
|
|
|
Ejecuta:
|
|
|
|
```bash
|
|
go run main.go
|
|
```
|
|
|
|
---
|
|
|
|
## 6. Requisitos de Fyne
|
|
|
|
### Windows
|
|
|
|
Instalar MSYS2 y añadir `C:\msys64\ucrt64\bin` al PATH.
|
|
|
|
```bash
|
|
pacman -S mingw-w64-ucrt-x86_64-toolchain
|
|
```
|
|
|
|
### Linux
|
|
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install gcc libgl1-mesa-dev xorg-dev
|
|
```
|
|
|
|
### macOS
|
|
|
|
```bash
|
|
xcode-select --install
|
|
```
|
|
|
|
---
|
|
|
|
## 7. Resumen
|
|
|
|
Go es ideal para:
|
|
|
|
- APIs y servicios backend
|
|
- herramientas CLI
|
|
- aplicaciones de escritorio con Fyne
|
|
- automatización y scripts del sistema
|