You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sleep.go
    path of file: ./repos/UpSnap/backend/networking
    
    the code of the file until where you have to start completion: package networking

import (
	"encoding/json"
	"errors"
	"fmt"

    
func SleepDevice(device *models.Record) (SolResponse, error) {
	logger.Info.Println("Sleep triggered for", device.GetString("name"))

	var solResp SolResponse
	var url string

	if device.GetBool("sol_auth") {
		url = fmt.Sprintf("http://%s:%s@%s:%d/sleep?format=JSON",
			device.GetString("sol_user"), device.GetString("sol_password"), device.GetString("ip"), device.GetInt("sol_port"))
	} else {
		url = fmt.Sprintf("http://%s:%d/sleep?format=JSON", device.GetString("ip"), device.GetInt("sol_port"))
	}

	resp, err := http.Get(url)
	if err != nil {
		return solResp, err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		body, err := io.ReadAll(resp.Body)
		if err != nil {
			return solResp, err
		}

		var solResp SolResponse
		if err := json.Unmarshal(body, &solResp); err != nil {
			return solResp, err
		}

		return solResp, errors.New("status code was not 200")
	}

	return solResp, nil
}