lib/weakhash, lib/model, cmd/syncthing: Decide if to use weakhash on startup (fixes #3938)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3949
This commit is contained in:
Audrius Butkevicius
2017-02-06 10:27:11 +00:00
parent 237893ead3
commit 67acef1794
12 changed files with 232 additions and 77 deletions

View File

@@ -25,6 +25,17 @@ func SetDefaults(data interface{}) error {
v := tag.Get("default")
if len(v) > 0 {
if parser, ok := f.Interface().(interface {
ParseDefault(string) (interface{}, error)
}); ok {
val, err := parser.ParseDefault(v)
if err != nil {
panic(err)
}
f.Set(reflect.ValueOf(val))
continue
}
switch f.Interface().(type) {
case string:
f.SetString(v)