---
title: "As"
description: "Convert a sequence of bytes into a sequence of proto.Message."
image: "https://tilebox.com/images/tilebox-docs-social-preview.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://tilebox.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# As

import { Fragment } from "astro/jsx-runtime";

import ApiReference from "@docs/components/ApiReference.astro";

import ParamField from "@docs/components/ParamField.astro";

```go
func As[T proto.Message](seq iter.Seq2[[]byte, error]) iter.Seq2[T, error]
```

Convert a sequence of bytes into a sequence of `proto.Message`.

Useful to convert the output of [`Datapoints.Query`](/docs/api-reference/go/datasets/Datapoints.Query) into a sequence of `proto.Message`.

## Parameters

**seq**

type: iter.Seq2[[]byte, error]

The sequence of bytes to convert

## Returns

A sequence of `proto.Message` or an error if any.

<h2 id="request-example">Usage example</h2>

```go
import (
  "time"
  datasets "github.com/tilebox/tilebox-go/datasets/v1"
	"github.com/tilebox/tilebox-go/query"
)

startDate := time.Date(
    2014, 10, 4, 0, 0, 0, 0, time.UTC,
)
endDate := time.Date(
    2021, 2, 24, 0, 0, 0, 0, time.UTC,
)
queryInterval := query.NewTimeInterval(
    startDate,
    endDate,
)

seq := datasets.As[*v1.Sentinel1Sar](
    client.Datapoints.Query(
      ctx,
      datasetID,
      datasets.WithCollectionIDs(collectionID),
      datasets.WithTemporalExtent(queryInterval),
    ),
)
```

Source: https://tilebox.com/docs/api-reference/go/datasets/As/index.mdx
