github.com/teknogeek/dnscontrol@v0.2.8/models/util.go (about)

     1  package models
     2  
     3  import (
     4  	"bytes"
     5  	"encoding/gob"
     6  	"strconv"
     7  
     8  	"github.com/pkg/errors"
     9  )
    10  
    11  func copyObj(input interface{}, output interface{}) error {
    12  	buf := &bytes.Buffer{}
    13  	enc := gob.NewEncoder(buf)
    14  	dec := gob.NewDecoder(buf)
    15  	if err := enc.Encode(input); err != nil {
    16  		return err
    17  	}
    18  	return dec.Decode(output)
    19  }
    20  
    21  // atou32 converts a string  to uint32 or panics.
    22  // DEPRECATED: This will go away when SOA record handling is rewritten.
    23  func atou32(s string) uint32 {
    24  	i64, err := strconv.ParseUint(s, 10, 32)
    25  	if err != nil {
    26  		panic(errors.Errorf("atou32 failed (%v) (err=%v", s, err))
    27  	}
    28  	return uint32(i64)
    29  }