Getting started with Go

R. S. Doiel,

Caltech Library, Digital Library Development

2025-09-26

Welcome to “Getting started with Go”

Welcome everyone,

This presentation is based on a blog post I wrote Getting started with Go

What we’ll learn

What you’ll need know

Installing Go compiler and tool chain

Go to the URL, the Go for your computer and operating system.

https://go.dev/dl/

Follow the instructions to install it.

Begin with Hello World

Source Code

package main

import (
    "fmt"
) 

func main() {
    fmt.Println("Hello World!")
}

Running Hello World

go run helloworld.go

Compiling Hello World

go build helloworld.go

Congratulations!

Continuing with a Web Server

Source Code

See https://pkg.go.dev/net/http#example-FileServer-DotFileHiding

Run Web Server

go run webserver.go

Compile Web Server

go build webserver.go

Things to notice

Wrapping up, putting things together

mdserver

create the following files

Or use curl to grab them.

curl -O https://caltechlibrary/presentations/mdserver/markdown.go
curl -O https://caltechlibrary/presentations/mdserver/handler.go
curl https://caltechlibrary/presentations/mdserver/cmd/mdserver/main.go \
  >cmd/mdserver/main.go

Initialize your package

go mod init 'github.com/caltechlibrary/mdserver'
go mod tidy

Pull in the goldmark package (Markdown)

go get "github.com/yuin/goldmark"

We use “go get” because this is not a standard library package.

Create a Markdown document to test with


# Hello World

This isn't HTML but you'll see HTML using mdserver

Save this as helloworld.md

Run mdserver

go run cmd/mdserver/main.go

Compile mdserver

go build -o bin/mdserver cmd/mdserver/main.go

Next steps