github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/scheme/example_test.go (about)

     1  package scheme_test
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/ydb-platform/ydb-go-sdk/v3"
     8  )
     9  
    10  func Example() {
    11  	ctx := context.TODO()
    12  	db, err := ydb.Open(ctx, "grpc://localhost:2136/local")
    13  	if err != nil {
    14  		fmt.Printf("failed to connect: %v", err)
    15  
    16  		return
    17  	}
    18  	defer db.Close(ctx) // cleanup resources
    19  	err = db.Scheme().MakeDirectory(ctx, "/local/test")
    20  	if err != nil {
    21  		fmt.Printf("failed to make directory: %v", err)
    22  	}
    23  	d, err := db.Scheme().ListDirectory(ctx, "/local/test")
    24  	if err != nil {
    25  		fmt.Printf("failed to list directory: %v", err)
    26  	}
    27  	fmt.Printf("list directory: %+v\n", d)
    28  }