vartanbeno / go-reddit

Go library for accessing the Reddit API.
Other
306 stars 84 forks source link

badger badger Blocked because of go-reddit and golang changes #38

Closed DaleEMoore closed 2 years ago

DaleEMoore commented 2 years ago

Howdy All y'all,

I'm looking for a little help in how to avoid the "badger badger" or "Blocked" issue that comes when using a golang version > 16 with go-reddit. Here is some background information:

I'm hoping that someone will lend me a hand crafting my normal call to this API:

sr, _, err := reddit.DefaultClient().Subreddit.Get(ctx, subreddit)

and turn off TLS.

Any help you can provide is very much appreciated!

DaleEMoore commented 2 years ago

Perhaps someone has thoughts about a good approach to making this

sr, _, err := reddit.DefaultClient().Subreddit.Get(ctx, subreddit)

have TLS turned off?

DaleEMoore commented 2 years ago

This solved my problem:

    var subreddit = "UpliftingNews"
    noTLS := reddit.WithHTTPClient(&http.Client{
        Transport: &http.Transport{
            TLSClientConfig: &tls.Config{},
        },
    })
    cl, err := reddit.NewReadonlyClient(noTLS)
    if err != nil {
        log.Println("NewClient err", err)
    }
    sr, re, err := cl.Subreddit.Get(ctx, subreddit)
    if err != nil {
        log.Println("Subreddit.Get err", err)
    }