Instructions: Setup Go Version 1.24.0, Manage Dependencies, Build, and Run
Prerequisites
Before proceeding, make sure you have the following installed on your computer:
- Go (Golang) version 1.24.0
- Make
Steps to Install Go 1.24.0
For Windows:
- Download the installer from official Go website.
- Run the downloaded
.msifile and follow the installation wizard. - During installation, you may be prompted to set the
GOPATHandGOROOT. Choose the appropriate settings based on your preference or keep the default values.
For macOS:
- Open Terminal.
- Download the package using Homebrew (if not installed, visit Homebrew website for
installation instructions):
brew install go@1.24 - Link the installed version to your PATH:
brew link --overwrite --force go@1.24
For Linux:
- Open Terminal.
- Download the appropriate tarball from official Go website.
- Extract the downloaded archive:
tar -C /usr/local -xzf go1.24.linux-amd64.tar.gz - Add Go to your PATH by editing your shell configuration file (e.g.,
.bashrc,.zshrc):echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc source ~/.bashrc
Verify Installation
After installation, verify that Go 1.24.0 is installed correctly by running:
go version
You should see an output like go version go1.24 darwin/amd64 (or similar, depending on your OS).
Install Make (if not already installed)
For Windows:
- Download and install Make for Windows.
- Add the installation directory to your PATH.
For macOS:
- Open Terminal.
- Install Make using Homebrew:
brew install make
For Linux:
Make is usually pre-installed on most Linux distributions. If it's not installed, you can install it using your
package manager (e.g., sudo apt-get install make for Ubuntu).
Navigate to Your Go Project Directory
Open Terminal and navigate to the root directory of your Go project.
Resolve Dependencies with go mod tidy
Run the following command to download and resolve all dependencies specified in your go.mod file:
go mod tidy
Build the Binary Using make build
Run the following command to build your project. The binary will be placed in the bin folder.
make build
Run the Program Using make run
Finally, you can run your program using:
make run
This command will compile and execute your Go application.
Note: Ensure that your Makefile is correctly set up to handle these commands. If not, you may need to create
or adjust it accordingly.
Please follow the above instructions to set up Go version 1.24.0, manage dependencies using `go mod tidy`, build a
binary with `make build`, and run your application with `make run`.