github.com/teknogeek/dnscontrol/v2@v2.10.1-0.20200227202244-ae299b55ba42/models/util.go (about) 1 package models 2 3 import ( 4 "bytes" 5 "encoding/gob" 6 ) 7 8 func copyObj(input interface{}, output interface{}) error { 9 buf := &bytes.Buffer{} 10 enc := gob.NewEncoder(buf) 11 dec := gob.NewDecoder(buf) 12 if err := enc.Encode(input); err != nil { 13 return err 14 } 15 return dec.Decode(output) 16 }