@@ -129,7 +129,8 @@ A release asset implements:
129129* ` Name() string`
130130* ` URL() * url.URL`
131131* ` ContentType() string`
132- * ` Size() uint32`
132+ * ` Size() uint32` — maximum representable size is ~ 4.29 GB (` math.MaxUint32` bytes). Assets larger than this will have
133+ their size truncated.
133134
134135# # Working with tags
135136
@@ -175,9 +176,8 @@ fmt.Println(tag.String())
175176
176177# ## Stream tags
177178
178- ` TagsStream` writes tags into a channel you provide.
179-
180- A safe consumption pattern is to run streaming in a goroutine and close the channel after it returns:
179+ ` TagsStream` writes tags into a channel you provide. The caller is responsible for closing the channel after the stream
180+ returns:
181181
182182` ` ` go
183183package main
@@ -201,7 +201,7 @@ func main() {
201201 ch := make(chan lightweigit.ProviderTagInterface, 32)
202202
203203 go func () {
204- defer close(ch)
204+ defer close(ch)
205205 _ = obj.TagsStream(ctx, ch, 0) // limit=0 means provider-defined/default behavior
206206 }()
207207
@@ -268,7 +268,7 @@ func main() {
268268 ch := make(chan lightweigit.ProviderReleaseInterface, 16)
269269
270270 go func () {
271- defer close(ch)
271+ defer close(ch)
272272 _ = obj.ReleasesStream(ctx, ch, 0)
273273 }()
274274
@@ -352,13 +352,15 @@ The library provides a shared HTTP client with a short timeout:
352352* ` lightweigit.HttpClient` defaults to 4 seconds
353353* ` lightweigit.ErrNotFound` is returned when the provider responds with HTTP 404
354354
355- If you need different networking settings (proxy, timeout, transport tuning), you can override the client:
355+ If you need different networking settings (timeout, proxy, custom TLS, transport tuning), you can replace the client
356+ before making any calls:
356357
357358` ` ` go
358359package main
359360
360361import (
361362 " net/http"
363+ " net/url"
362364 " time"
363365
364366 lightweigit " github.com/voluminor/lightweigit-loader"
@@ -371,6 +373,35 @@ func main() {
371373}
372374` ` `
373375
376+ Example with HTTP proxy:
377+
378+ ` ` ` go
379+ proxyURL, _ := url.Parse(" http://proxy.example.com:8080" )
380+ lightweigit.HttpClient = & http.Client{
381+ Timeout: 10 * time.Second,
382+ Transport: & http.Transport{
383+ Proxy: http.ProxyURL(proxyURL),
384+ },
385+ }
386+ ` ` `
387+
388+ Example with SOCKS5 proxy (requires ` golang.org/x/net/proxy` ):
389+
390+ ` ` ` go
391+ lightweigit.HttpClient = & http.Client{
392+ Timeout: 10 * time.Second,
393+ Transport: & http.Transport{
394+ Proxy: http.ProxyURL(& url.URL{
395+ Scheme: " socks5" ,
396+ Host: " 127.0.0.1:1080" ,
397+ }),
398+ },
399+ }
400+ ` ` `
401+
402+ > ** Note:** ` lightweigit.HttpClient` is a shared global variable. Changing it affects all providers and all goroutines
403+ > in the process. Set it once during initialization before making any API calls.
404+
374405# # Design notes
375406
376407* Dependency-free (standard library only)
0 commit comments