- Go installed: Ensure you have Go installed on your system. You can download it from https://go.dev/dl/.
- This project use go version 1.23.2, so make sure you update or install the same or version as the source code.
- Terminal: You'll need a terminal or command prompt to execute the commands.
-
Open your terminal: Open the terminal application on your operating system.
-
Navigate to the project directory: Use the
cdcommand to go to the directory containing the Go code (the directory with themain.gofile).cd project/pathReplace
project/pathwith the actual path to the project. -
Inside the project directory run the following command to execute the code.
go run main.go
-
Open your terminal: Open the terminal application on your operating system.
-
Navigate to the project directory: Use the
cdcommand to go to the directory containing the Go code (the directory with themain.gofile).cd project/pathReplace
project/pathwith the actual path to the project. -
Building for macOS:
-
Set the target operating system:
export GOOS=darwin -
Set the target architecture (if needed, defaults to your machine's):
export GOARCH=amd64 # For Intel Macs export GOARCH=arm64 # For Apple Silicon Macs -
Build the executable:
go build -o myappThe executable will be named
myapp.
-
-
Building for Windows:
-
Set the target operating system:
export GOOS=windows -
Set the target architecture:
export GOARCH=amd64 # For 64-bit Windows export GOARCH=386 # For 32-bit Windows -
Build the executable:
go build -o myapp.exeThe executable will be named
myapp.exe.
-
After successfully building the project, you can run the executable:
-
Open a terminal: Open a terminal or command prompt.
-
Navigate to the directory: Use the
cdcommand to go to the directory where the executable file is located (the same directory where you ran thego buildcommand). -
Run the executable:
-
On macOS, type
./followed by the executable name:./myapp -
On Windows, type the executable name with the
.exeextension:myapp.exe
-
Replace myapp with the actual name of your application.