DEV Community

Discussion on: 12 Personal Go Tricks That Transformed My Productivity

 
mikeschinkel profile image
Mike Schinkel • Edited

Interesting idea about the "required" tag. I can see where that would be useful for ensuring that types have required values, although I do like to minimize dependencies so unless I felt the need to use a lot of its functionality I would likely still shy away.

OTOH, it would not be hard to implement a required tag of my own and not require a dependency, so thanks; that is something for me to consider.

As for args, I have used the strategy of positional required args and optional args as structs for over well more than a decade and across numerous languages and have found it to be easy to be consistent and have never found it to fail me, so I doubt I personally would want to change to using all parameters in structs.

I do wish that Go and other languages had more bespoke functionality for dealing with required and optional parameters such as an automatic struct optional args, as well as multiple stacks for things like context.Context and error that might not be added initially but that could be discovered to be needed later. However, we do have to live in the world we've got and not in the one we only envision.

But we as both agreed on these topics, #fwiw. 🙂