DEV Community

Cover image for Getting started with go
dwarfŧ
dwarfŧ

Posted on

Getting started with go

go (or golang) is a popular programming language that can be used for backend but also frontend in some cases.

1. installation
i am using mac to run go and here is the installation process:
if you have the admin password just install the package but if you don't follow the installation tutorial
1)download the binaries:
download the go binaries on the go download page they have the file ending tar.gz and unzip it in your home folder
2)linking the binaries:
most macOS terminals run in zsh so run the command: nano .zshrc (make sure you are in the home directory) and you will be taken on to the edit page.
3)editing the .zshrc:
on the top line add the code: export PATH="${HOME}/go/bin:${PATH}" then close with ctrl+x, y then ENTER.
4)done :)
refresh the terminal by reopening it and test it is installed by running the command go

2. writing the code
because this is an introduction we will only write a hello world program:

package main
import "fmt"
func main() {
    fmt.Println("hello world")
}
Enter fullscreen mode Exit fullscreen mode

3.running
to run we can do the command: go run main.go

final step
enjoying programming and have a nice day :)

Top comments (0)