Azure-sdk-for-go: Error when attempting to create a Resource Group client

Created on 23 Apr 2020  路  3Comments  路  Source: Azure/azure-sdk-for-go

Bug Report

I am attempting to retrieve a group object, however it seems to always error about not enough arguments etc as per below:

go build
# github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:120:2: not enough arguments to return
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:120:15: client.Send undefined (type DeploymentOperationsClient has no field or method Send)
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:208:2: not enough arguments to return
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:208:15: client.Send undefined (type DeploymentOperationsClient has no field or method Send)
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:292:2: not enough arguments to return
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:292:15: client.Send undefined (type DeploymentOperationsClient has no field or method Send)
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:385:2: not enough arguments to return
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:385:15: client.Send undefined (type DeploymentOperationsClient has no field or method Send)
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:513:2: not enough arguments to return
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:513:15: client.Send undefined (type DeploymentOperationsClient has no field or method Send)
../../../go/pkg/mod/github.com/!azure/[email protected]+incompatible/services/resources/mgmt/2019-05-01/resources/deploymentoperations.go:513:2: too many errors

Below is the go code I am executing, I have mostly pilfered from the go SDK example assuming I was doing something completely wrong in my initial implementation. However, it seems as this returns the same results.

package main

import (
    "context"

    "github.com/Azure/go-autorest/autorest/azure/auth"
    "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources"
)

const (
    SubscriptionID = ""
    GroupName = ""
)

func main() {
    ctx := context.Background()

    rg, err := GetGroup(ctx)
    if err != nil {
        return err
    }

    fmt.Printf("group: %s", rg)
}

func GetGroupsClient() resources.GroupsClient{
    client := resources.NewGroupsClient(SubscriptionID)

    a, err := auth.NewAuthorizationFromEnvironment()
    if err != nil {
        return err
    }

    client.Authorizer = a

    return client
}

func GetGroup(ctx context.Context) (resource.Group, error) {
    groupsClient := GetGroupsClient()

    return groupsClient.Get(ctx, GroupName)
}

Here is my go.mod for this as well:

module azure

go 1.14

require (
    github.com/Azure/azure-sdk-for-go v41.3.0+incompatible
    github.com/Azure/go-autorest/autorest/azure/auth v0.4.2
    github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect
    github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect
)

customer-reported question versioning

All 3 comments

Hi @BrendanThompson thanks for this issue!
The root cause of this issue is that the go SDK has to be used accompany by the corresponding version of go-autorest labeled in Gopkg.toml, aka >v14.0.0+incompatible (or equivalent module versions, such as github.com/Azure/go-autorest/autorest v0.10.0)

For more relative information, you could refer to this issue

@ArcturusZhang apologies for terrible delay. That certainly did resolve the issue for me, thank you :)

In case anyone is looking for a quick fix -
go get -u github.com/Azure/go-autorest/autorest
worked for me.

Was this page helpful?
0 / 5 - 0 ratings