Go Struct Embedding Gotcha: Ambiguous Fields

2025-09-22

Go's struct embedding, while powerful for composing types, presents a potential pitfall. When embedded structs share field names, like multiple embedded structs both having a `URL` field, the compiler unexpectedly prioritizes the least nested field. This code demonstrates this subtle issue, printing `abc.com` instead of a compilation error as might be expected. Exercise caution when using struct embedding to avoid ambiguous field names and potential runtime surprises.

Read more

Go's Design: A Deliberate Trade-Off

2025-01-31

This article delves into the design philosophy of the Go programming language, exploring its strengths and weaknesses. Born at Google, Go aimed to simplify writing and maintaining large-scale concurrent server code. The author analyzes Go's features – its simplified filesystem API, lack of operator overloading, explicit error handling, and interoperability with other languages – to explain the trade-offs behind its design choices. While criticized for aspects like its former lack of generics and less-than-stellar Windows support, the author argues these are conscious compromises made to achieve its primary design goals, ultimately making Go an efficient and easy-to-use language for engineering large projects.

Read more