2018-02-15 12:02:50 -05:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/gob"
|
Switch to Go 1.13 error wrapping (#604)
* Replaced errors.Wrap with fmt.Errorf (#589)
* Find: errors\.Wrap\(([^,]+),\s+(["`][^"`]*)(["`])\)
Replace: fmt.Errorf($2: %w$3, $1)
* Replaced errors.Wrapf with fmt.Errorf (#589)
* Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])\)
Replace: fmt.Errorf($2: %w$3, $1)
* Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])(,[^)]+)\)
* Replace: fmt.Errorf($2: %w$3$4, $1)
* Replaced errors.Errorf with fmt.Errorf (#589)
* Find: errors\.Errorf
Replace: fmt.Errorf
* Cleaned up remaining imports
* Cleanup
* Regenerate provider support matrix
This was broken by #533 ... and it's now the third time this has been missed.
2020-01-28 11:06:56 -05:00
|
|
|
"fmt"
|
2018-02-15 12:02:50 -05:00
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func copyObj(input interface{}, output interface{}) error {
|
|
|
|
buf := &bytes.Buffer{}
|
|
|
|
enc := gob.NewEncoder(buf)
|
|
|
|
dec := gob.NewDecoder(buf)
|
|
|
|
if err := enc.Encode(input); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return dec.Decode(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
// atou32 converts a string to uint32 or panics.
|
|
|
|
// DEPRECATED: This will go away when SOA record handling is rewritten.
|
|
|
|
func atou32(s string) uint32 {
|
|
|
|
i64, err := strconv.ParseUint(s, 10, 32)
|
|
|
|
if err != nil {
|
Switch to Go 1.13 error wrapping (#604)
* Replaced errors.Wrap with fmt.Errorf (#589)
* Find: errors\.Wrap\(([^,]+),\s+(["`][^"`]*)(["`])\)
Replace: fmt.Errorf($2: %w$3, $1)
* Replaced errors.Wrapf with fmt.Errorf (#589)
* Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])\)
Replace: fmt.Errorf($2: %w$3, $1)
* Find: errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])(,[^)]+)\)
* Replace: fmt.Errorf($2: %w$3$4, $1)
* Replaced errors.Errorf with fmt.Errorf (#589)
* Find: errors\.Errorf
Replace: fmt.Errorf
* Cleaned up remaining imports
* Cleanup
* Regenerate provider support matrix
This was broken by #533 ... and it's now the third time this has been missed.
2020-01-28 11:06:56 -05:00
|
|
|
panic(fmt.Errorf("atou32 failed (%v) (err=%v", s, err))
|
2018-02-15 12:02:50 -05:00
|
|
|
}
|
|
|
|
return uint32(i64)
|
|
|
|
}
|