2016-11-21 71 views
-1

我在golang以下功能:如何更改導入文件?

import (
    "github.com/aws/aws-sdk-go/service/iam" 
    "github.com/aws/aws-sdk-go/aws/session" 
    "fmt" 
) 
func NewIAM() *SphinxIAM { 
// awsConfig := aws.NewConfig() 
    sess, err := session.NewSession() 
    if err != nil { 
     fmt.Println("Failed to create session,", err) 
     return nil 
    } 
    session := &SphinxIAM{iam: iam.New(sess)} 
    return session 
} 

現在,我收到以下錯誤,當我運行此:

cannot use sess (type *session.Session) as type "github.com/aws/aws-sdk-go/aws/client".ConfigProvider in argument to iam.New: 
    *session.Session does not implement "github.com/aws/aws-sdk-go/aws/client".ConfigProvider (wrong type for ClientConfig method) 
     have ClientConfig(string, ...*"stash/cloud/sphinx/vendor/github.com/aws/aws-sdk-go/aws".Config) "stash/cloud/sphinx/vendor/github.com/aws/aws-sdk-go/aws/client".Config 
     want ClientConfig(string, ...*"github.com/aws/aws-sdk-go/aws".Config) "github.com/aws/aws-sdk-go/aws/client".Config 

我不得不改變越來越導入的方法,但我怎麼準確去做?

謝謝!

回答

0

這裏的問題是,你的github.com/aws/aws-sdk-go/aws/session包是出售,它從文件夾stash/cloud/sphinx/vendor/github.com/aws/aws-sdk-go/aws加載。

但是,您想要通過它的功能:iam.New()未銷售,它不是來自同一供應商文件夾(stash/cloud/sphinx/vendor/xxx),而是直接來自github.com/aws/aws-sdk-go/service/iam

要麼將​​這兩個軟件包放在同一個供應商文件夾下,要麼沒有。您的某個依賴項工具可能會這樣做(例如glide),在這種情況下,您應該指示您的工具以兼職方式處理這兩者。