This repository is designed to help beginners get started with Golang. Below is a quick guide to installing, setting up, and using Go effectively.
Ensure that you have Go installed. To check the installed version of Go, run:
go version
Configure your Go environment:
go env -w GO111MODULE=off
Run your Go application:
- To run a Go application from the current directory:
go run .
- To run a specific Go file:
go run filename.go
For help with Go commands:
go help
Go code is grouped into packages, and packages are grouped into modules. To explore packages, visit pkg.go.dev.
Initialize your Go module using:
go env -w GO111MODULE=on ## need to set, so as to init or install modules..
go mod init [module-path]
go mod init hello
To add external packages to your Go module:
go get -v rsc.io/quote
The go mod tidy
command will ensure that your dependencies are in order:
- It adds missing dependencies.
- It removes unused ones.
Run it with:
go mod tidy
Compile and build your Go project:
go build
- To build a specific Go file:
go build filename.go
To list the modules and their dependencies:
go list
- Official Go Documentation: golang.org/doc
- Explore Go Packages: pkg.go.dev