From a2d5b04d5890462d62b6ee3e3826bd209a750209 Mon Sep 17 00:00:00 2001 From: antanst Date: Mon, 10 Mar 2025 11:33:56 +0200 Subject: [PATCH] Fix linter warnings in gemini/network.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove redundant nil checks before len() operations as len() for nil slices is defined as zero in Go. 🤖 Generated with [Claude Code](https://claude.ai/code) --- gemini/network.go | 9 ++++----- gopher/network.go | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/gemini/network.go b/gemini/network.go index 384f6b1..bc1c674 100644 --- a/gemini/network.go +++ b/gemini/network.go @@ -17,7 +17,6 @@ import ( _url "gemini-grc/common/url" "gemini-grc/config" "gemini-grc/logging" - "github.com/antanst/go_errors" "github.com/guregu/null/v5" ) @@ -217,17 +216,17 @@ func getMimeTypeAndLang(headers string) (int, string, string) { // - Only capturing the lang value, ignoring charset re := regexp.MustCompile(`^(\d+)\s+([a-zA-Z0-9/\-+]+)(?:(?:[\s;]+(?:charset=[^;\s]+|lang=([a-zA-Z0-9-]+)))*)\s*$`) matches := re.FindStringSubmatch(headers) - if matches == nil || len(matches) <= 1 { + if len(matches) <= 1 { // If full format doesn't match, try to match redirect format: " " // This handles cases like "31 gemini://example.com" re := regexp.MustCompile(`^(\d+)\s+(.+)$`) matches := re.FindStringSubmatch(headers) - if matches == nil || len(matches) <= 1 { + if len(matches) <= 1 { // If redirect format doesn't match, try to match just a status code // This handles cases like "99" re := regexp.MustCompile(`^(\d+)\s*$`) matches := re.FindStringSubmatch(headers) - if matches == nil || len(matches) <= 1 { + if len(matches) <= 1 { return 0, "", "" } code, err := strconv.Atoi(matches[1]) @@ -253,4 +252,4 @@ func getMimeTypeAndLang(headers string) (int, string, string) { func isGeminiCapsule(s *snapshot.Snapshot) bool { return !s.Error.Valid && s.MimeType.Valid && s.MimeType.String == "text/gemini" -} +} \ No newline at end of file diff --git a/gopher/network.go b/gopher/network.go index e6c8c22..4e33857 100644 --- a/gopher/network.go +++ b/gopher/network.go @@ -17,7 +17,6 @@ import ( _url "gemini-grc/common/url" "gemini-grc/config" "gemini-grc/logging" - "github.com/antanst/go_errors" "github.com/guregu/null/v5" )