跳到主要内容
版本:v2.5.x

ListCollections()

This method lists all existing collections.

Go
func (c *Client) ListCollections(ctx context.Context, option ListCollectionOption, callOptions ...grpc.CallOption) (collectionNames []string, err error)

Request Parameters​

Parameter

Description

Type

ctx

Context for the current call to work.

context.Context

option

Optional parameters of the methods.

ListAliasesOption

callOpts

Optional parameters for calling the methods.

grpc.CallOption

ListCollectionOption​

This is an interface type. The listCollectionOption struct type implements this interface type.

You can use the NewListCollectionOption() function to get the concrete implementation.

NewListCollectionOption​

The signature of this method is as follows:

Go
func NewListCollectionOption() *listCollectionOption

Return​

[]string

Example​

Go
import (
"context"
"github.com/milvus-io/milvus/client/v2/milvusclient"
)

collectionNames, err := cli.ListCollections(ctx, milvusclient.NewListCollectionOption())
if err != nil {
// handle error
}

fmt.Println(collectionNames)