Since go-autorest and azure-sdk-for-go committed vendor directories (https://github.com/Azure/azure-sdk-for-go/commit/b99be020a281cae39761deadb8672d22f44b89eb, https://github.com/Azure/go-autorest/commit/ce88814cecd48039e38c31553e7499883ae95d8c), the signature of NewAccountSASClient changed unexpectedly, making the following code failing to compile:
import (
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest/azure"
"net/url"
)
func main() {
env, _ := azure.EnvironmentFromName("AZUREPUBLICCLOUD")
client := storage.NewAccountSASClient(account, query, env)
}
cannot use env (type "github.com/Azure/go-autorest/autorest/azure".Environment)
as type "github.com/Azure/azure-sdk-for-go/vendor/github.com/Azure/go-autorest/autorest/azure".Environment
in argument to storage.NewAccountSASClient
If useful, the project does not use go modules, dep or any other dependency manager.
See https://github.com/Azure/azure-sdk-for-go/pull/4254#issuecomment-471928712 for more detailed example.
@jhendrixMSFT
It's not that the signature changed, it's that the types are different; i.e. the vendored copy of azure.Environment is a different type than your local copy of azure.Environment even though the signatures are identical.
Signature includes parameter types, so I guess if the type changed, the signature changed as well.
More importantly, any idea how can I fix it?
I was discussing this with @vladbarosan, unfortunately go get and dep are somewhat diametrically opposed so finding a solution that works for both is difficult. We highly recommend using a package version management system like dep but I guess this isn't always desirable.
Can using go modules (the official way) solve the issue? We will still use go get, but it'll be module-aware.
Modules will solve this and is ultimately where we want to land although that's at least a month out. In the meantime I believe the other options are to either switch your projects to use dep for package management or we remove go-autorest (and a few other packages) from the vendor directory.
This has been fixed in https://github.com/Azure/azure-sdk-for-go/releases/tag/v26.3.1, sorry for the hassle.
@jhendrixMSFT - thanks for the quick fix! 馃帀
will be great if you can also add an example with the above code to make sure compilation will not break with next dependencies fix :)
@aviaoh thanks for reminding me, will look into that today.
Since the vendor directory has been removed and README also has been updated, I suppose this issue should be considered as resolved and I will close this issue.
Most helpful comment
This has been fixed in https://github.com/Azure/azure-sdk-for-go/releases/tag/v26.3.1, sorry for the hassle.