运行命令“ go get”时收到警告

时间:2020-04-14 12:33:26

标签: pointers go interface nextcloud

大家好, 我已经在包装内编写了以下代码

import "gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud"

type ConfigNextCloud struct {
    URL      string `json:"url"`
    Username string `json:"username"`
    Password string `json:"password"`
}

func LoadNextCloudProperty(fullFileName string) (ConfigNextCloud, error) { // fullFileName for fetching database credentials from  given JSON filename.
    var configNextCloud ConfigNextCloud
    // Open and read the file
    fileHandle, err := os.Open(fullFileName)
    if err != nil {
        return configNextCloud, err
    }
    defer fileHandle.Close()

    jsonParser := json.NewDecoder(fileHandle)
    jsonParser.Decode(&configNextCloud)

    // Display Information about NextCloud Instance.
    fmt.Println("Read NextCloud configuration from the ", fullFileName, " file")
    fmt.Println("URL\t", configNextCloud.URL)
    fmt.Println("Username \t", configNextCloud.Username)
    fmt.Println("Password \t", configNextCloud.Password)

    return configNextCloud, nil
}

func ConnectToNextCloud(fullFileName string) (*gonextcloud.Client, error) {
    configNextCloud, err := LoadNextCloudProperty(fullFileName)
    //
    if err != nil {
        log.Printf("Loading NextCloudProperty: %s\n", err)
        return nil, err
    }

    fmt.Println("Connecting to NextCloud...")

    nextCloudClient, err := gonextcloud.NewClient(configNextCloud.URL)
    if err != nil {
        fmt.Println("Client creation error:", err)
    }

    if err = nextCloudClient.Login(configNextCloud.Username, configNextCloud.Password); err != nil {
        fmt.Println("Login Error", err)
    }
    defer nextCloudClient.Logout()
    return nextCloudClient, err // return the NextcloudClient created to perform the download and store actions
}

包含aboce代码的软件包在另一个文件中使用。 完整的项目已部署在github上。当我尝试运行go get命令以安装项目时,收到以下警告:

cannot use nextCloudClient (type gonextcloud.Client) as type *gonextcloud.Client in return argument:
        *gonextcloud.Client is pointer to interface, not interface

尽管如此,当我运行go build命令时,代码未显示任何错误。 请帮助我解决这个特有的问题。

0 个答案:

没有答案