O'Reilly logo

Go Web Development Cookbook by Arpit Aggarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works…

Once we run the program, the HTTP server will start locally listening on port 8080. Browsing http://localhost:8080 will show us the same output we saw in our previous recipe, but this time the text color has changed from the default black to blue, as shown in the following image:

If we look at the Network tab of Chrome DevTools, we can see main.css, which has been loaded from the static/css directory present on the filesystem.

Let's understand the changes we introduced in the main() method as part of this recipe:

  • fileServer := http.FileServer(http.Dir("static")): Here, we created a file server using the FileServer handler of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required