Go's structural typing system for interfaces creates implementation challenges despite its conceptual simplicity. The inability to add default methods to interfaces without breaking existing code leads to messy APIs like flag.Value. A workaround using struct embedding with unexported methods can simulate default implementations

10m read timeFrom mcyoung.xyz
Post cover image
Table of contents
flag.Value is a MessStruct EmbeddingsUsing DefaultsShouldn’t This Be a Language Feature?Conclusion
1 Comment

Sort: