func main() {
	milvusAddr := `localhost:19530`
	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
	defer cancel()
	c, err := client.NewGrpcClient(ctx, milvusAddr)
	if err != nil {
		log.Fatal("failed to connect to milvus:", err.Error())
	}
	collectionName := `gosdk_basic_collection`
	collExists, err := c.HasCollection(ctx, collectionName)
	if err != nil {
		log.Fatal("failed to check collection exists:", err.Error())
	}
	if collExists {
		_ = c.DropCollection(ctx, collectionName)
	}
	schema := &entity.Schema{
		CollectionName: collectionName,
		Description:    "this is the basic example collection",
		AutoID:         true,
		Fields: []*entity.Field{
			{
				Name:       "int64",
				DataType:   entity.FieldTypeInt64,
				PrimaryKey: true,
				AutoID:     true,
			},
			{
				Name:     "vector",
				DataType: entity.FieldTypeFloatVector,
				TypeParams: map[string]string{  
					"dim": "128",
				},
			},
		},
	}
	err = c.CreateCollection(ctx, schema, 2)  
	if err != nil {
		log.Fatal("failed to create collection:", err.Error())
	}
	collections, err := c.ListCollections(ctx)
	if err != nil {
		log.Fatal("failed to list collections:", err.Error())
	}
	for _, collection := range collections {
		log.Printf("Collection id: %d, name: %s\n", collection.ID, collection.Name)
	}
	log.Println("New collection with partitions:")
	partitions, err := c.ShowPartitions(ctx, collectionName)
	if err != nil {
		log.Fatal("failed to show partitions:", err.Error())
	}
	for _, partition := range partitions {
		log.Printf("partition id: %d, name: %s\n", partition.ID, partition.Name)
	}
	partitionName := "new_partition"
	err = c.CreatePartition(ctx, collectionName, partitionName)
	if err != nil {
		log.Fatal("failed to create partition:", err.Error())
	}
	log.Println("After create partition")
	partitions, err = c.ShowPartitions(ctx, collectionName)
	if err != nil {
		log.Fatal("failed to show partitions:", err.Error())
	}
	for _, partition := range partitions {
		log.Printf("partition id: %d, name: %s\n", partition.ID, partition.Name)
	}
	_ = c.DropCollection(ctx, collectionName)
	c.Close()
}
basic milvus operation example
package main
import (
	"context"
	"log"
	"time"
	"github.com/milvus-io/milvus-sdk-go/v2/client"
	"github.com/milvus-io/milvus-sdk-go/v2/entity"
)