// Copy creates a copy of an error.
340714
func Copy(ie interface{}) error {
	if ie == nil {
		return nil
	}
	switch e := ie.(type) {
	case *Error:
		return e.Copy()
	case error:
		val := reflect.ValueOf(e)
		if types.AnySettableValue(val) {
			return types.Copy(val).Interface().(error)
		}
		return errors.New(e.Error())
	default:
		panic("type not supported")
	}
}
386847
func (sc *SetComprehension) Copy() *SetComprehension {
	cpy := *sc
	cpy.Body = sc.Body.Copy()
	cpy.Term = sc.Term.Copy()
	return &cpy
}
224325
func (c *Config) Copy() *Config {
	copy := *c

	if c.XHR != nil {
		xhr := *copy.XHR
		copy.XHR = &xhr
	}

	if c.Client != nil {
		client := *copy.Client
		copy.Client = &client
	}

	if c.Websocket != nil {
		ws := *copy.Websocket
		copy.Websocket = &ws
	}

	return &copy
}
1204959
func (oc *ObjectComprehension) Copy() *ObjectComprehension {
	cpy := *oc
	cpy.Body = oc.Body.Copy()
	cpy.Key = oc.Key.Copy()
	cpy.Value = oc.Value.Copy()
	return &cpy
}
543970
func (r *RawConfig) Copy() *RawConfig {
	if r == nil {
		return nil
	}

	r.lock.Lock()
	defer r.lock.Unlock()

	if r.Body != nil {
		return NewRawConfigHCL2(r.Body)
	}

	newRaw := make(map[string]interface{})
	for k, v := range r.Raw {
		newRaw[k] = v
	}

	result, err := NewRawConfig(newRaw)
	if err != nil {
		panic("copy failed: " + err.Error())
	}

	result.Key = r.Key
	return result
}
1158701
func (r *Request) copy() *Request {
	req := &Request{}
	*req = *r
	req.Handlers = r.Handlers.Copy()
	op := *r.Operation
	req.Operation = &op
	return req
}
495274
func (l *DiagnosticLog) Copy(ctx context.Context, w io.Writer) (int, error) {
	const max = 500 // VC max == 500, ESX max == 1000
	written := 0

	for {
		h, err := l.m.BrowseLog(ctx, l.Host, l.Key, l.Start, max)
		if err != nil {
			return 0, err
		}

		for _, line := range h.LineText {
			n, err := fmt.Fprintln(w, line)
			written += n
			if err != nil {
				return written, err
			}
		}

		l.Start += int32(len(h.LineText))

		if l.Start >= h.LineEnd {
			break
		}
	}

	return written, nil
}
1095676
func (obj *object) Copy() Object {
	cpy, _ := obj.Map(func(k, v *Term) (*Term, *Term, error) {
		return k.Copy(), v.Copy(), nil
	})
	return cpy
}
972666
func (r *Request) copy() *Request {
	r.state.Lock()
	defer r.state.Unlock()
	r2 := new(Request)
	*r2 = *r
	return r2
}
632862
func Copy(src interface{}) interface{} {
	if src == nil {
		return nil
	}

	// Make the interface a reflect.Value
	original := reflect.ValueOf(src)

	// Make a copy of the same type as the original.
	cpy := reflect.New(original.Type()).Elem()

	// Recursively copy the original.
	copyRecursive(original, cpy)

	// Return the copy as an interface.
	return cpy.Interface()
}
814076
func (br *ResponseBuffer) Copy(w http.ResponseWriter) error {
	for k, v := range br.sent {
		w.Header()[k] = v
	}
	w.WriteHeader(br.code)
	_, err := io.Copy(w, br)
	return err
}
234533
func Copy(l Logger) Logger {
	if l, ok := l.(LoggerCopier); ok {
		return l.Copy()
	}
	return NopLogger
}
173914
func (renderer *Renderer) Copy(texture *Texture, src, dst *Rect) error {
	return errorFromInt(int(
		C.SDL_RenderCopy(
			renderer.cptr(),
			texture.cptr(),
			src.cptr(),
			dst.cptr())))
}
878759
func Copy(dst string, src string) error {
	from, err := os.Open(src)
	if err != nil {
		return fmt.Errorf(`can't copy %s: %v`, src, err)
	}
	defer from.Close()
	finfo, err := from.Stat()
	if err != nil {
		return fmt.Errorf(`can't stat %s: %v`, src, err)
	}
	to, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, finfo.Mode())
	if err != nil {
		return fmt.Errorf(`can't copy to %s: %v`, dst, err)
	}
	defer to.Close()
	_, err = io.Copy(to, from)
	if err != nil {
		return fmt.Errorf(`error copying %s to %s: %v`, src, dst, err)
	}
	return nil
}
761360
func Copy(src, dst string) (err error) {
	var cmd *exec.Cmd
	src, dst = Abs(src), Abs(dst)
	// Determine the command we need to use.
	if runtime.GOOS == "windows" {
		// *NOTE* Not sure this will work correctly, we don't have Windows to test.
		if IsFile(src) {
			cmd = exec.Command("copy", src, dst)
		} else {
			cmd = exec.Command("xcopy", src, dst, "/S /E")
		}
	} else {
		cmd = exec.Command("rsync", "-a", src, dst)
	}

	if stdout, err := cmd.StdoutPipe(); err == nil {
		if stderr, err := cmd.StderrPipe(); err == nil {
			// Start capturing the stdout/err.
			err = cmd.Start()
			io.Copy(os.Stdout, stdout)
			buffer := new(bytes.Buffer)
			buffer.ReadFrom(stderr)
			cmd.Wait()
			if cmd.ProcessState.String() != "exit status 0" {
				err = fmt.Errorf("\t%s\n", buffer.String())
			}
		}
	}
	return
}
383231
func Copy(src, dest string) error {
	info, err := os.Lstat(src)
	if err != nil {
		return err
	}
	return copy(src, dest, info)
}
806450
func (that *JSONNode) Copy(other *JSONNode, deepCopy bool) *JSONNode {
	if that.t != TypeUndefined {
		panic(ErrorCopyType)
	}

	if other.t == TypeValue {
		*that = *other
	} else if other.t == TypeArray {
		if !deepCopy {
			*that = *other
		} else {
			that.Array(len(other.a))
			for i := range other.a {
				that.At(i).Copy(other.At(i), deepCopy)
			}
		}
	} else if other.t == TypeMap {
		that.SetType(other.t)
		if !deepCopy {
			for val := range other.m {
				that.m[val] = other.m[val]
			}
		} else {
			for val := range other.m {
				that.Map(val).Copy(other.At(val), deepCopy)
			}
		}
	}
	return that
}