How can I find blob using blob index tags in golang

Could you please help me how can I find blob using blob index tags in GoLang

One common service for this purpose is Azure Blob Storage, which supports metadata and tags for blobs.

Here’s a simple example using the Azure Storage SDK for Go. Make sure to install the SDK before using it:

go get -u

Now, you can use the following code to find a blob using blob index tags:

package main

import (


func main() {
	accountName := "your_account_name"
	accountKey := "your_account_key"
	containerName := "your_container_name"
	blobName := "your_blob_name"

	// Create a Storage Account credential using your account name and key
	credential, err := azblob.NewSharedKeyCredential(accountName, accountKey)
	if err != nil {

	// Create a pipeline using your Storage Account credential
	pipeline := azblob.NewPipeline(credential, azblob.PipelineOptions{})

	// Create a blob URL
	blobURL := azblob.NewContainerURL(
		azblob.NewServiceURL(fmt.Sprintf("", accountName), pipeline),

	// Get blob properties including metadata and tags
	getBlobResp, err := blobURL.GetBlob(context.Background(), azblob.BlobRange{}, azblob.BlobAccessConditions{}, false)
	if err != nil {

	// Access blob metadata and tags
	blobMetadata := getBlobResp.NewMetadata()
	blobTags := getBlobResp.BlobTags()

	// Find the blob using blob index tags
	if blobTags != nil {
		for key, value := range blobTags {
			// Check if the desired tag is present
			if strings.ToLower(key) == "your_tag_key" && strings.ToLower(value) == "your_tag_value" {
				// Perform actions on the blob, e.g., print its metadata
				fmt.Println("Blob Metadata:", blobMetadata)

	fmt.Println("Blob with specified tag not found.")

Replace placeholders like "your_account_name," "your_account_key," "your_container_name," "your_blob_name," "your_tag_key," and "your_tag_value" with your actual Azure Storage account information.

This example assumes you're using Azure Blob Storage, and the tags are set as metadata for the blob. If you're using a different storage service or have a different setup, the approach might differ. Always refer to the documentation of the specific storage service you are using.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.