a repo for my Go Language learning
https://go.dev/doc/tutorial/getting-started
sudo apt install golang-go
mkdir folder; cd folder
go mod init folder/file
this gives a pseudo link for local Go.mod
to reference. Name it the same as the folder your code will be in with main or hello.gotouch hello.go
go run .
- for an executable file
go build hello.go
which compiles and makeshello
file =>./hello
check out packages https://pkg.go.dev/ but all of the Go packages are from GitHub.
to import a package:
go get -u github.com/
, example:go get -u github.com/ttacon/chalk
- inside the main file import the github link inside the
import( )
, example:import( "fmt"; "github.com/ttacon/chalk" )
- run
go mod tidy
for package maintenance - run program
go run .
Go lang does not like when you have packages imported or variables etc declared and not used, comment the things not used to avoid any errors or warnings.
Starter template
package main
import "fmt"
var pl = fmt.Println // declare a shortcut for fmt.Println
func main() {
pl("hello Go")
}