Simple programm

Init a go program

A simple go program

If you want to start simple, you may use only one main.go file.

  1. Create a working directory:

mkdir simple && cd simple

So we have a working directory.

  1. go mod init simple

That initializes the module named “simple” and creates the file go.mod:

└── go.mod
  1. vi main.go

Now we edit a single file - which can be called as you like, but usually is called “main.go”

package main

import (

func main() {

The package named “main” is predefined and has to contain a function named “main”, which will be the starting point for your program.

At this point we do not really use modules, we just have one file.


go run main.go



Let’s add some more files


See the full source on github.