Difficulty: Beginner
Estimated Time: 10 minutes

This is a Golang scenario to test skill on the Go programming language. The scenario is currently based on Go 1.12.

The $GOPATH variable is set to /gopath. The $GOROOT variable is set to /goroot.

A terminal and a file editer are provided to modify the source code files and test the configurations.

Follow the guided steps and the interviewer hints to complete the assessment.

Golang Demo

Step 1 of 3

Step 1

Configure an minimal http server

Complete the missing source code

The provided source file defines an incomplete http server. The following packages have been already imported:

  • fmt
  • log
  • net/http

Complete the helloFunc function to write the message "Hello World" in the HTTP response upon an HTTP GET method.

Define the http.HandleFunc call in the main goroutine in order to call helloFunc on the "/hello" endpoint.

Print the following log message on startup: "Starting http server on port 8080".

Save and test the results with the following command:

$ go run main.go

Initialize a Go module

Define a Go module (feature introduced in Go 1.11) in the current directory using github.com/extraordy/http-server as the module name.

To find out how to configure the module use the following command:

$ go mod help

Build the static binary

Build a binary and copy it under /usr/local/bin, using a single build command. Use the following command for the build help:

$ go help build

Test the binary by running it and connecting on port 8080:

$ /usr/local/bin/http-server
This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]