Hello, World

What I learned

Few rules to writing tests

Didn't work

# installing local documentation
go install golang.org/x/tools/cmd/godoc@latest

# after installing this command still don't work
godoc -http :8000
# ERROR: 'godoc' command not found

Starting a module

create the hello module:

mkdir hello
cd hello
go mod init hello
# check if the "go.mod" file was created


package main

import "fmt"

// Hello() is a separated function
// to make it testable
func Hello() string {
  return "Hello, world"

func main() {


package main

import "testing"

func TestHello(t *testing.T) {
  got := Hello()
  want := "Hello, world"

  if got != want {
    t.Errorf("got %q want %q", got, want)

Run the test:

go test