style: apply structpack & goimport (#469)

* refactor: reorder import statements in fetch.go and fetch_test.go

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

* fix: optimize struct field alignment to reduce memory usage

Signed-off-by: Jason Cameron <git@jasoncameron.dev>

---------

Signed-off-by: Jason Cameron <git@jasoncameron.dev>
This commit is contained in:
Jason Cameron 2025-05-09 12:54:15 -04:00 committed by GitHub
parent 8c7640aa09
commit 529f65674e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 60 additions and 61 deletions

View file

@ -158,12 +158,12 @@ func TestGetOGTagsWithHostConsideration(t *testing.T) {
}
testCases := []struct {
name string
ogCacheConsiderHost bool
requests []struct {
name string
requests []struct {
host string
expectedLoadCount int // Expected load count *after* this request
expectedLoadCount int
}
ogCacheConsiderHost bool // Expected load count *after* this request
}{
{
name: "Host Not Considered - Same Host",

View file

@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"golang.org/x/net/html"
"io"
"log/slog"
"mime"
"net"
"net/http"
"golang.org/x/net/html"
)
var (

View file

@ -2,7 +2,6 @@ package ogtags
import (
"fmt"
"golang.org/x/net/html"
"io"
"net/http"
"net/http/httptest"
@ -10,6 +9,8 @@ import (
"strings"
"testing"
"time"
"golang.org/x/net/html"
)
func TestFetchHTMLDocument(t *testing.T) {

View file

@ -56,10 +56,10 @@ func TestIntegrationGetOGTags(t *testing.T) {
// Test with different configurations
testCases := []struct {
expectedTags map[string]string
name string
path string
query string
expectedTags map[string]string
expectError bool
}{
{

View file

@ -20,12 +20,12 @@ const (
type OGTagCache struct {
cache *decaymap.Impl[string, map[string]string]
targetURL *url.URL
ogCacheConsiderHost bool
ogPassthrough bool
ogTimeToLive time.Duration
client *http.Client
approvedTags []string
approvedPrefixes []string
client *http.Client
ogTimeToLive time.Duration
ogCacheConsiderHost bool
ogPassthrough bool
}
func NewOGTagCache(target string, ogPassthrough bool, ogTimeToLive time.Duration, ogTagsConsiderHost bool) *OGTagCache {

View file

@ -18,9 +18,9 @@ func TestExtractOGTags(t *testing.T) {
testCache.approvedPrefixes = []string{"og:"}
tests := []struct {
expected map[string]string
name string
htmlStr string
expected map[string]string
}{
{
name: "Basic OG tags", // Includes standard 'description' meta tag

View file

@ -104,10 +104,11 @@ const (
type action string
type testCase struct {
name string
action action
isHard bool
realIP, userAgent string
name string
action action
realIP string
userAgent string
isHard bool
}
func doesNPXExist(t *testing.T) {

View file

@ -65,12 +65,12 @@ func TestXForwardedForUpdateAddToChain(t *testing.T) {
func TestComputeXFFHeader(t *testing.T) {
for _, tt := range []struct {
err error
name string
remoteAddr string
origXFFHeader string
pref XFFComputePreferences
result string
err error
pref XFFComputePreferences
}{
{
name: "StripPrivate",