Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Usage" code in Readme #33

Merged
merged 2 commits into from
Feb 7, 2025
Merged

Fix "Usage" code in Readme #33

merged 2 commits into from
Feb 7, 2025

Conversation

TAbdiukov
Copy link
Contributor

@TAbdiukov TAbdiukov commented Jul 6, 2024

Description

The example code in README.md in incorrect (and probably outdated). This PR fixes this.

Change can be viewed here: 7c7cc2c

p := proxy.NewProvider("").Get("https", "https://rapid7.com")

is changed to,

p := proxy.NewProvider("").GetProxy("https", "https://rapid7.com")

I decided to create this PR, as I tried to use this code and found a fault in readme .

Testing

Below is the list of confirmations for the need for example code to be fixed.

Firstly: I ran the code myself

  • I ran the example code, and here is the listing.

C:\Projects\PR-tests>cat test_for_PR1.go
package main
import (
    "fmt"
    "github.com/rapid7/go-get-proxied/proxy"
)
func main() {
    p := proxy.NewProvider("").Get("https", "https://rapid7.com")
    if p != nil {
        fmt.Printf("Found proxy: %s\n", p)
    }
}

C:\Projects\PR-tests>go run test_for_PR1.go
# command-line-arguments
.\test_for_PR1.go:7:32: proxy.NewProvider("").Get undefined (type proxy.Provider
 has no field or method Get)

C:\Projects\PR-tests>
  • However, corrected code does work,

C:\Projects\PR-tests>cat test_for_PR2.go
package main
import (
    "fmt"
    "github.com/rapid7/go-get-proxied/proxy"
)
func main() {
    p := proxy.NewProvider("").GetProxy("https", "https://rapid7.com")
    if p != nil {
        fmt.Printf("Found proxy: %s\n", p)
    }
}

C:\Projects\PR-tests>go run test_for_PR2.go
Found proxy: WinHTTP:NamedProxy|://1.1.1.1:80

C:\Projects\PR-tests>

Secondly: I checked upstream code, and, there is type Provider interface, which does not define Get, but does define GetProxy,

GetProxy(protocol string, targetUrl string) Proxy

Thirdly: Third-party code also uses GetProxy(), for example, here: https://github.com/keyring-so/keyring-desktop/blob/9c6ca18257fee150f922d7559a85e7270373bcdc/app.go#L80

In light of these factors, I'm making this Push Request.

@TAbdiukov
Copy link
Contributor Author

My changes were approved. Let me know if I need to do anything my end

@mmohan-r7 mmohan-r7 merged commit 0911287 into rapid7:master Feb 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants