Golang
Patterns
Good Resources
- Slice Tricks
- Slice Tricks Cheat Sheet
- The ecosystem of the Go programming language
- CodeReviewComments
- Darker Corners of Go
- Practical Go Lessons
- Learn Go with Tests
- Going infinite handling 1M websockets connections in Go
- Going infinite handling 1M websockets connections in Go - GitHub
- Package Management in Go
- Go Programming Language
- Google Go Style
- Clean Go Code
Testing code that uses goroutines
I’m using github.com/stretchr/testify/mock
:
type SomeService struct {
}
func (ss *SomeService) SomeMethod(parameter string) {
go doSomethingElse()
}
func doSomethingElse() {
// some thing we want to do
}
type SomeServiceMock struct {
mock.Mock
wg sync.WaitGroup
}
func (ss *SomeServiceMock) SomeMethod(parameter string) {
defer ss.wg.Done()
ss.Called(parameter)
}
func TestSomething(t *testing.T) {
someService := new(SomeServiceMock)
someService.wg.Add(1)
someService.On("SomeMethod", "someParameter").Return(nil).Times(1)
// execute code that we want to test using the someService mock
someService.wg.Wait()
mock.AssertExpectationsForObjects(t, someService)
}
Convert float to string
s := fmt.Sprintf("%f", 123.456) // s == "123.456000"
Books
Cool Projects
- Typer
- PTerm
- bokchoy - simple Go library for queueing tasks
- coffee - tool for studying parallelism, contention, utilization, latency, and throughput
- conc - better structured concurrency for go
Frameworks
ORM
Tools
- Autostrada - Application scaffold generator
- Statsviz - Real time Go runtime metrics
- Eventhus - CQRS/ES toolkit for Go
- gocov - Coverage reporting tool for The Go Programming Language
Swagger on Go projects
- Super complete tool: https://github.com/go-swagger/go-swagger
- More simpler one with annotations support: https://github.com/swaggo/swag
Interesting Posts
- Concurrent API Patterns in Go @ DeliveryHero Tech
- Introducing Clean Architecture by refactoring a Go project
- Introducing basic CQRS by refactoring a Go project
- Too modern Go application? Building a serverless application with Google Cloud Run and Firebase
- The Repository pattern: a painless way to simplify your Go service logic
- You should not build your own authentication. Let Firebase do it for you
- A complete Terraform setup of a serverless application on Google Cloud Run and Firebase
- Repository secure by design: how to sleep better without fear of security vulnerabilities
- Microservices test architecture. Can you sleep well without end-to-end tests?
- Combining DDD, CQRS, and Clean Architecture by refactoring a Go project
- Common Anti-Patterns in Go Web Applications
- 4 practical principles of high-quality database integration tests in Go
- Introduction to DDD Lite: When microservices in Go are not enough
- Robust gRPC communication on Google Cloud Run (but not only!)
- Modern Business Software in Go - Series of posts
- Safer Enums in Go
- The Go libraries that never failed us: 22 libraries you need to know
- JSON vs FlatBuffers vs Protocol Buffers