jbogarin / go-cisco-webex-teams

Cisco Webex Teams Go SDK
MIT License
35 stars 25 forks source link

Resty v2 Go Modules Compatibility Error #7

Closed seanmalloy closed 5 years ago

seanmalloy commented 5 years ago

Similar to #6 i'm seeing the below error when trying to use Go Modules to build my project. I'm using Go Lang version 1.12.9.

CGO_ENABLED=0 GO111MODULE=on go build -o prom2webex
go: finding github.com/google/go-querystring/query latest
go: github.com/go-resty/resty@v1.12.0: parsing go.mod: unexpected module path "gopkg.in/resty.v1"
go: error loading module requirements

Here is main.go ...

package main

import (
        "fmt"
        "log"

        webexteams "github.com/jbogarin/go-cisco-webex-teams/sdk"
)

// Client is Webex Teams API client
// var Client *webexteams.Client

func main() {
        // Client is Webex Teams API client
        Client := webexteams.NewClient()

        // TODO: remove hard coded roomID
        myRoomID := "myroomid"

        // POST messages - Text Message
        message := &webexteams.MessageCreateRequest{
                Text:   "This is a text message fo testing",
                RoomID: myRoomID,
        }
        newTextMessage, _, err := Client.Messages.CreateMessage(message)
        if err != nil {
                log.Fatal(err)
        }
        fmt.Println("POST:", newTextMessage.ID, newTextMessage.Text, newTextMessage.Created)

        // POST messages - Markdown Message
        //markDownMessage := &webexteams.MessageCreateRequest{
        //      Markdown: "This is a markdown message. *Italic*, **bold** and ***italic/bold***.",
        //      RoomID:   myRoomID,
        //}
        //newMarkDownMessage, _, err := Client.Messages.CreateMessage(markDownMessage)
        //if err != nil {
        //      log.Fatal(err)
        //}
        //fmt.Println("POST:", newMarkDownMessage.ID, newMarkDownMessage.Markdown, newMarkDownMessage.Created)
}

Here is go.mod ...

module path/to/my/project

go 1.12

require github.com/jbogarin/go-cisco-webex-teams v0.3.0

require github.com/go-resty/resty/v2 v2.0.0

According to the resty v2 doc the correct import path for using resty v2 with Go Modules is import "github.com/go-resty/resty/v2".

https://github.com/go-resty/resty#installation https://github.com/go-resty/resty#usage

Can/should the code in this project we updated to import "github.com/go-resty/resty/v2" instead of "github.com/go-resty/resty"?

seanmalloy commented 5 years ago

@jbogarin I submitted pull request #8 with a proposed fix for this issue. I confirmed that my project now compiles using Go Modules using my proposed changes. Let me know what you think.

My updated go.mod file ...

module path/to/my/project

go 1.12

require github.com/jbogarin/go-cisco-webex-teams v0.3.0

// Work around issue with github.com/jbogarin/go-cisco-webex-teams Go Module support
replace github.com/jbogarin/go-cisco-webex-teams => github.com/KohlsTechnology/go-cisco-webex-teams v0.3.1-0.20190923041206-1f5a3fb1071a
jbogarin commented 5 years ago

PR #8 merged. Closing this issue

darrenparkinson commented 4 years ago

Hi, I don't think this is fixed?

jbogarin commented 4 years ago

@darrenparkinson do you need me to reopen this? I honestly just merge the PR. But if you need me to run more tests, I can do it.

seanmalloy commented 4 years ago

@darrenparkinson are you not able to use this library with go modules after #8 was merged? Can you provide more details on the problem you are seeing? Is there are error message?

darrenparkinson commented 4 years ago

Hi, thanks for the response. Apologies for the delay.

So yes, creating a new simple module and running it results in the same error. Does it need a new release?

go.mod:

module github.com/whatever/mytestapp

go 1.14

require github.com/jbogarin/go-cisco-webex-teams v0.3.0 // indirect

Error:

go: finding module for package github.com/peterhellberg/link
go: finding module for package github.com/google/go-querystring/query
go: finding module for package github.com/go-resty/resty
go: found github.com/go-resty/resty in github.com/go-resty/resty v1.12.0
go: found github.com/google/go-querystring/query in github.com/google/go-querystring v1.0.0
go: found github.com/peterhellberg/link in github.com/peterhellberg/link v1.1.0
go: github.com/jbogarin/go-cisco-webex-teams/sdk imports
        github.com/go-resty/resty: github.com/go-resty/resty@v1.12.0: parsing go.mod:
        module declares its path as: gopkg.in/resty.v1
                but was required as: github.com/go-resty/resty
seanmalloy commented 4 years ago

@darrenparkinson you have to use master instead of v0.3.0 until a new release is created.

jbogarin commented 4 years ago

That's my bad. I'm trying to add some of the new APIs like devices, places and such. I'll get to it this week and create a new release.