> So depending on the algorithm you are using, you are going to leave some of these fields in the struct as null/empty?
In Go, when you create a new variable, it's automatically set to the null/zero value. So in this case, they would be nil.
In Go, when you create a new variable, it's automatically set to the null/zero value. So in this case, they would be nil.
So not the same thing with default values at all.
With this struct interface you just implement "optional" values...
In skein package:
var DefaultHash = &Args{ ... } // the default args you want
Users will call it like this: skein.New(32, &skein.DefaultHash)
Another way, better for some cases, is have methods on arguments struct, like in base32 package from stdlib http://golang.org/pkg/encoding/base32/ base32.StdEncoding.DecodeToString(...)
base32.HexEncoding.DecodeToString(...)
In most cases (but now all), there are better ways to design API than stuff them with default arguments, which make functions behave unexpectedly if you forget something.But maybe we should talk about specific cases? What are the examples of functions which need to accept default arguments? Maybe I can try to convert them into something reasonable in Go?