News for hackers. Stuff that matters.
Re:Reusable and type-safe options for Go APIs by everdev on Sunday October 22, 2017 @01:07PM (#15527762)
For the zero value problem, a pointer is usually used rather than an "identifier value" like -1.

var price *float64

if price == nil {

  // Handle empty value

}
Re:Reusable and type-safe options for Go APIs by sfifs on Sunday October 22, 2017 @08:26PM (#15529832)
This works if you can guarantee the variable will not ever change after being set which is not unreasonable for configuration options.

However if you are dealing with variables that can mutate in a concurrent environment, you might have a race condition if you pass by pointer reference rather than by value