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 versionConfigure your Go environment:
go env -w GO111MODULE=offRun your Go application:
- To run a Go application from the current directory:
go run .- To run a specific Go file:
go run filename.goFor help with Go commands:
go helpGo 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 helloTo add external packages to your Go module:
go get -v rsc.io/quoteThe 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 tidyCompile and build your Go project:
go build- To build a specific Go file:
go build filename.goTo list the modules and their dependencies:
go list- Official Go Documentation: golang.org/doc
- Explore Go Packages: pkg.go.dev