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: query.go
    path of file: ./repos/steampipe/cmd
    
    the code of the file until where you have to start completion: package cmd

import (
	"bufio"
	"context"
	"encoding/json"
	"fmt"
	"os"
	"path"
	"strings"

	"github.com/hashicorp/hcl/v2"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"github.com/turbot/go-kit/helpers"
	"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
	"github.com/turbot/steampipe/pkg/cmdconfig"
	"github.com/turbot/steampipe/pkg/connection_sync"
	"github.com/turbot/steampipe/pkg/constants"
	"github.com/turbot/steampipe/pkg/contexthelpers"
	"github.com/turbot/steampipe/pkg/dashboard/dashboardexecute"
	"github.com/turbot/steampipe/pkg/dashboard/dashboardtypes"
	"github.com/turbot/steampipe/pkg/display"
	"github.com/turbot/steampipe/pkg/error_helpers"
	"github.com/turbot/steampipe/pkg/query"
	"github.com/turbot/steampipe/pkg/query/queryexecute"
	"
    
func executeSnapshotQuery(initData *query.InitData, ctx context.Context) int {
	// start cancel handler to intercept interrupts and cancel the context
	// NOTE: use the initData Cancel function to ensure any initialisation is cancelled if needed
	contexthelpers.StartCancelHandler(initData.Cancel)

	// wait for init
	<-initData.Loaded
	if err := initData.Result.Error; err != nil {
		exitCode = constants.ExitCodeInitializationFailed
		error_helpers.FailOnError(err)
	}

	// if there is a custom search path, wait until the first connection of each plugin has loaded
	if customSearchPath := initData.Client.GetCustomSearchPath(); customSearchPath != nil {
		if err := connection_sync.WaitForSearchPathSchemas(ctx, initData.Client, customSearchPath); err != nil {
			exitCode = constants.ExitCodeInitializationFailed
			error_helpers.FailOnError(err)
		}
	}

	for _, resolvedQuery := range initData.Queries {
		// if a manual query is being run (i.e. not a named query), convert into a query and add to workspace
		// this is to allow us to use existing dashboard execution code
		queryProvider, existingResource := ensureSnapshotQueryResource(resolvedQuery.Name, resolvedQuery, initData.Workspace)

		// we need to pass the embedded initData to  GenerateSnapshot
		baseInitData := &initData.InitData

		// so a dashboard name was specified - just call GenerateSnapshot
		snap, err := dashboardexecute.GenerateSnapshot(ctx, queryProvider.Name(), baseInitData, nil)
		if err != nil {
			exitCode = constants.ExitCodeSnapshotCreationFailed
			error_helpers.FailOnError(err)
		}

		// set the filename root for the snapshot (in case needed)
		if !existingResource {
			snap.FileNameRoot = "query"
		}

		// display the result
		switch viper.GetString(constants.ArgOutput) {
		case constants.OutputFormatNone:
			// do nothing
		case constants.OutputFormatSnapshot, constants.OutputFormatSnapshotShort:
			// if the format is snapshot, just dump it out
			jsonOutput, err := json.MarshalIndent(snap, "", "  ")
			if err != nil {
				error_helpers.FailOnErrorWithMessage(err, "failed to display result as snapshot")
			}
			fmt.Println(string(jsonOutput))
		default:
			// otherwise convert the snapshot into a query result
			result, err := snapshotToQueryResult(snap)
			error_helpers.FailOnErrorWithMessage(err, "failed to display result as snapshot")
			display.ShowOutput(ctx, result, display.WithTimingDisabled())
		}

		// share the snapshot if necessary
		err = publishSnapshotIfNeeded(ctx, snap)
		if err != nil {
			exitCode = constants.ExitCodeSnapshotUploadFailed
			error_helpers.FailOnErrorWithMessage(err, fmt.Sprintf("failed to publish snapshot to %s", viper.GetString(constants.ArgSnapshotLocation)))
		}

		// export the result if necessary
		exportArgs := viper.GetStringSlice(constants.ArgExport)
		exportMsg, err := initData.ExportManager.DoExport(ctx, snap.FileNameRoot, snap, exportArgs)
		error_helpers.FailOnErrorWithMessage(err, "failed to export snapshot")
		// print the location where the file is exported
		if len(exportMsg) > 0 && viper.GetBool(constants.ArgProgress) {
			fmt.Printf("\n")
			fmt.Println(strings.Join(exportMsg, "\n"))
			fmt.Printf("\n")
		}
	}
	return 0
}