news.volyx.in

How to start a Go project in 2023 (boyter.org)

443 points by taylorbuley · 1194 days ago · 198 comments on HN

Article summary

The article provides an updated guide on how to start a Go project in 2023, covering topics such as installation, setting up a project, learning resources, and best practices for testing, linting, and security scanning. It also discusses various tools and libraries that can be useful for Go development, including Goland, Visual Studio Code, and goreleaser. The article aims to help new Go developers get started and be productive. The guide covers various aspects of Go development, from setting up a project to deploying and maintaining it.

Main themes

  • Go project setup
  • Testing and mocking
  • Logging and error handling
  • Web frameworks and libraries
  • Dependency management
  • Binary size optimization
  • Containerization and Docker
  • Development tools and best practices

What commenters say

  • Some developers prefer using non-Go specific file watchers like reflex, while others use Go-specific tools like GOW.
  • The use of build tags for integration tests can lead to tests being out of sync with the main code, and alternative approaches like using environment variables or CLI flags are suggested.
  • There is disagreement on whether Go needs web frameworks, with some arguing that they are not necessary and others claiming that they are essential for building robust and secure applications.
  • Some developers recommend using targeted libraries instead of full-fledged frameworks, while others prefer using frameworks like Cobra or Chi.
  • The choice of logging library is also debated, with some preferring zerolog and others suggesting slog, which is expected to become part of the standard library.
  • There is a need for better tools for binary size analysis and reduction, with some developers suggesting the use of goda for dependency analysis.
  • The importance of testing and mocking is emphasized, with some developers preferring manual mocking and others using tools like testify and mockery.
  • The use of Docker and containerization is also discussed, with some developers recommending the use of testcontainers for integration testing.