feat: Add linter configuration and improve error handling in download functions
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- errcheck
|
||||||
|
- govet
|
||||||
|
- staticcheck
|
||||||
|
- unused
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
- path: examples/
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
- unused
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
tests: true
|
||||||
|
|
||||||
|
output:
|
||||||
|
format: colored-line-number
|
||||||
|
print-issued-lines: true
|
||||||
|
print-linter-name: true
|
||||||
|
sort-results: true
|
||||||
@@ -249,7 +249,7 @@ func (c *Client) downloadWithBasicAuth(ctx context.Context, downloadURL string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("download request failed: %w", err)
|
return nil, fmt.Errorf("download request failed: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
bodyPreview, _ := io.ReadAll(resp.Body)
|
bodyPreview, _ := io.ReadAll(resp.Body)
|
||||||
@@ -328,7 +328,7 @@ func (c *Client) downloadWithDigestAuth(ctx context.Context, downloadURL string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("digest auth request failed: %w", err)
|
return nil, fmt.Errorf("digest auth request failed: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
bodyPreview, _ := io.ReadAll(resp.Body)
|
bodyPreview, _ := io.ReadAll(resp.Body)
|
||||||
|
|||||||
@@ -610,7 +610,7 @@ func (c *CLI) tryRTSPConnection(streamURI string) map[string]interface{} {
|
|||||||
// Try to connect
|
// Try to connect
|
||||||
conn, err := net.DialTimeout("tcp", hostPort, 3*time.Second)
|
conn, err := net.DialTimeout("tcp", hostPort, 3*time.Second)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
conn.Close()
|
_ = conn.Close() // Ignore error on close for connectivity check
|
||||||
details["reachable"] = true
|
details["reachable"] = true
|
||||||
details["port"] = strings.Split(hostPort, ":")[1]
|
details["port"] = strings.Split(hostPort, ":")[1]
|
||||||
return details
|
return details
|
||||||
|
|||||||
Reference in New Issue
Block a user