如何使用Go SDK列出Azure存储中的共享

I have download "go get github.com/Azure/azure-storage-file-go/azfile" this library.

Now I am trying to list shares, files and directories using Go SDK.

But I am stuck. How to call listshare function and also how to authenticate it using Shared key.

Here is my sample code for you. Hope it helps.

package main

import (
    "context"
    "fmt"
    "log"
    "net/url"

    "github.com/Azure/azure-storage-file-go/azfile"
)

func main() {
    accountName, accountKey := "<your account name>", "<your account key>"
    credential, _ := azfile.NewSharedKeyCredential(accountName, accountKey)
    serviceURL, _ := url.Parse("https://<your account name>.file.core.windows.net/")
    p := azfile.NewPipeline(credential, azfile.PipelineOptions{})
    service := azfile.NewServiceURL(*serviceURL, p)
    list, _ := service.ListSharesSegment(context.Background(), azfile.Marker{}, azfile.ListSharesOptions{})
    for i, item := range list.ShareItems {
        fmt.Println(i, item)
    }
}