Înapoi la articole →

Cel mai recent articol

Ultima verificare

Urmăritori 0 urmăritori
Articole: 54
  1. How I use HTMX with Go

    When I want to add sprinkles of interactivity to a web application, I'm a big fan of using HTMX.

  2. Go Experiments Explained

    Go often ships with experimental features as part of a release.

  3. Choosing the right names in your codebase is an important (and sometimes difficult!)

  4. Go 1.25 introduced a new http.CrossOriginProtection middleware to the standard library — and it got me wondering: Have we finally reached the point where CSRF attacks can be prevented without relying on a token-based check (like double-submit cookies)?

  5. A few weeks ago Anton Zhiyanov published the blog post Expressive tests without testify/assert.

  6. When I'm building a web application in Go, I prefer to use command-line flags to pass configuration settings to the application at runtime.

  7. For many years, I've used third-party packages to help organize and manage middleware in my Go web applications.

  8. If you've been working with Go for a while, you might be familiar with the Go proverb "don't panic".

  9. One of my favourite features of Go 1.24 is the new functionality for managing developer tooling dependencies.

  10. When working with Go, you have three main building blocks to help organize your code: files, packages and modules.

  11. In almost all web applications that I build, I end up needing to persist some data – either for a short period of time (such as caching the result of an expensive database query), or for the lifetime of the running application until it is restarted.

  12. In this post we're going to talk about how (and why!)

  13. Whenever I start a new Go project, one of the first things I do is create a Makefile in the root of my project directory.

  14. One of my favorite things about the recent Go 1.20 release is the new http.ResponseController type, which brings with it three nice benefits: You can now override your server-wide read and write deadlines on a per request basis.

  15. This tutorial is written for anyone who is new to Go.

  16. In this post we're going to run through how to use cookies in your Go web application to persist data between HTTP requests for a specific client.

  17. In this post I'd like to talk about one of my favorite architectural patterns for building web applications and APIs in Go.

  18. Last year I wrote a new HTTP router for Go called Flow.

  19. When you're working on a project it's common for there to be some developer tooling dependencies.

  20. Now that Go 1.18 has been released with support for generics, it's easier than ever to create helper functions for your test assertions.

  21. In this post we're going to walk through how to use GitHub Actions to create a continuous integration (CI) pipeline that automatically tests, vets and lints your Go code.

  22. In this short post we're going to discuss how to add, modify or delete URL query string parameters in Go.

  23. Note: This post has been fully updated to reflect the new http.ServeMux features released in Go 1.22.

  24. Recently I've been building a fully internationalized (i18n) and localized (l10n) web application for the first time with Go's golang.org/x/text packages.

  25. When searching for examples of HTTP basic authentication with Go, every result I found unfortunately contained code which was either out-of-date (i.e. doesn't use the r.BasicAuth() functionality that was introduced in Go 1.4) or failed to mitigate the risk

  26. One of my favorite things about the recent Go 1.16 release is a small — but very welcome — addition to the flag package: the flag.Func() function.

  27. This is a list of things about Go's encoding/json package which, over the years, have either confused or surprised me when I first encountered them.

  28. One of the great features of Go's database/sql package is that it's possible to cancel database queries while they are still running via a context.Context instance.

  29. Let's say that you're building a JSON API with Go.

  30. For the past few months I've been running a survey which asks people what they're finding difficult about learning Go.

  31. PostgreSQL provides two JSON-related data types that you can use — JSON and JSONB.

  32. Occasionally I get asked “why do you like using Go?”

  33. Thanks to Andreas Auernhammer, author of the golang.org/x/crypto/argon2 package, for checking over this post before publication.

  34. For the past couple of years I've used Sublime Text as my primary code editor, along with the GoSublime plugin to provide some extra IDE-like features.

  35. A.K.A.

  36. Earlier this year AWS announced that their Lambda service would now be providing first-class support for the Go language, which is a great step forward for any gophers (like myself) who fancy experimenting with serverless technology.

  37. A nice feature of Go's http.FileServer is that it automatically generates navigable directory listings, which look a bit like this: But for certain applications you might want to prevent this behavior and disable directory listings altogether.

  38. There are a lot of good tutorials which talk about Go's sql.DB type and how to use it to execute SQL database queries and statements.

  39. If you're running a HTTP server and want to rate limit user requests, the go-to package to use is probably Tollbooth by Didip Kerabat.

  40. Over the past few years I've built up a collection of snippets for validating inputs in Go.

  41. I’ve just released SCS, a session management package for Go 1.7+.

  42. Working with Redis

    In this post I'm going to be looking at using Redis as a data persistence layer for a Go application.

  43. A few weeks ago someone created a thread on Reddit asking: In the context of a web application what would you consider a Go best practice for accessing the database in (HTTP or other) handlers?

  44. This is the first in a series of tutorials about persisting data in Go web applications.

  45. I've written a package for chaining context-aware handlers in Go, called Stack.

  46. When you're building a web application, there's probably some shared functionality that you want to run for many (or even all) HTTP requests.

  47. Often in web applications you need to temporarily store data in-between requests, such as an error or success message during the Post-Redirect-Get process for a form submission.

  48. In this post I want to outline a sensible pattern that you can use for validating and processing HTML forms in Go web applications.

  49. Taking inspiration from the Rails layouts and rendering guide, I thought it'd be a nice idea to build a snippet collection illustrating some common HTTP responses for Go web applications.

  50. Understanding Mutexes

    For anyone new to building web applications with Go, it's important to realise that all incoming HTTP requests are served in their own Goroutine.