52 lines
876 B
Markdown
52 lines
876 B
Markdown
**AYUDA Go**
|
|
=========
|
|
|
|
**https://https://go.dev/
|
|
|
|
-------------------
|
|
|
|
**Flujo correcto siempre en Go**
|
|
|
|
Cada proyecto:
|
|
|
|
mkdir mi-proyecto\
|
|
cd mi-proyecto\
|
|
go mod init nombre\
|
|
go get dependencia\
|
|
go run main.go
|
|
|
|
--------
|
|
|
|
go mod init agenda
|
|
go get modernc.org/sqlite
|
|
go run agenda.go
|
|
|
|
⚠️ MUY IMPORTANTE (para SQLite)
|
|
Recuerda esto o te dará error después:
|
|
sudo apt install build-essential
|
|
|
|
**Crear ejecutable**
|
|
|
|
Dentro de tu proyecto:
|
|
go build -o agenda
|
|
Esto genera:
|
|
agenda
|
|
|
|
▶️ Ejecutarlo
|
|
./agenda
|
|
|
|
🪟 Para Windows
|
|
go build -o agenda.exe
|
|
|
|
🌍 Cross-compiling (MUY potente)
|
|
Puedes compilar para otros sistemas desde Linux:
|
|
|
|
Windows:
|
|
GOOS=windows GOARCH=amd64 go build -o agenda.exe
|
|
Linux:
|
|
GOOS=linux GOARCH=amd64 go build -o agenda
|
|
Mac:
|
|
GOOS=darwin GOARCH=amd64 go build -o agenda
|
|
|
|
-------------------
|