Intro to Golang
Select a place where to store your project. If you don’t have one in mind,
~/code/
could be a good start.
Creating a go module
You need to select a unique identifier for your project, called a module path,
so that people can locate and import code from it. If you have a domain, a
common convention is to use a URL that you have control over. I personally use
github.com/AlexanderHOtt/<project name>
, but if you have a domain you want to
use, it could be <project name>.example.com
.
You should have a new file named “go.mod” with similar contents below
- go.mod
Hello World
Create a new file named “main.go”.
- All go files must be a part of a package. The default package is “main”.
- Go import statements have the package name in double quotes.
- The
main
function is the default entry point of the go program.
Change the program so that it prints your name.
What is the keyword to create function in Go?
- fn
- fun
- func
- function
What is the function we use to print?
Print
print
Println
println