To build your application for different platforms, you can set the GOOS and GOARCH environment variables. Here’s how to build for Windows, Linux, and macOS:
For Windows:
GOOS=windows GOARCH=amd64 go build -o MyApp.exe main.go
For Linux:
GOOS=linux GOARCH=amd64 go build -o MyApp main.go
For macOS:
GOOS=darwin GOARCH=amd64 go build -o MyApp main.go