refactor: remove unnecessary codes
Kim committed
Mar 4, 2026 at 16:23 UTC
ac8272ed8d50ec71935f99733a5a1bcd5797c1c1
7 files changed
+9
-43
.golangci.yml
-5
@@ -26,7 +26,6 @@ linters:
26
- durationcheck
27
- makezero
28
- noctx
29
- - revive
29
- wastedassign
30
- misspell
31
- whitespace
@@ -51,10 +50,6 @@ linters:
50
source: "^\\s*defer\\s+"
51
- path: "_test\\.go"
52
linters: [bodyclose, errcheck, noctx, wrapcheck, funlen, dupl]
54
- - text: "should have a package comment"
55
- linters: [revive]
56
- - text: "exported \\S+ \\S+ should have comment"
57
- linters: [revive]
53
54
settings:
55
errcheck:
cmd/relay-server/utils.go
+1
-1
@@ -207,7 +207,7 @@ func (r *leaseRow) fromLeaseEntry(entry *portal.LeaseEntry, admin *Admin, portal
207
r.Link = ""
208
}
209
r.StaleRed = !connected && since >= leaseConnectedWindow
210
- r.Hide = entry.ParsedMetadata != nil && entry.ParsedMetadata.Hide
210
+ r.Hide = metadata.Hide
211
r.Metadata = metadataStr
212
r.BPS = bps
213
portal/lease.go
+8
-21
@@ -1,7 +1,6 @@
1
package portal
2
3
import (
4
- "encoding/json"
4
"regexp"
5
"strings"
6
"sync"
@@ -22,11 +21,10 @@ type Lease struct {
21
22
// LeaseEntry represents a registered lease with expiration tracking.
23
type LeaseEntry struct {
25
- Lease *Lease
26
- Expires time.Time
27
- LastSeen time.Time
28
- FirstSeen time.Time
29
- ParsedMetadata *types.ParsedMetadata // Cached parsed metadata
24
+ Lease *Lease
25
+ Expires time.Time
26
+ LastSeen time.Time
27
+ FirstSeen time.Time
28
}
29
30
type LeaseManager struct {
@@ -143,16 +141,6 @@ func (lm *LeaseManager) UpdateLease(lease *Lease) bool {
141
}
142
}
143
146
- // Parse metadata once for cached access
147
- var parsedMeta *types.ParsedMetadata
148
- metadataJSON, _ := json.Marshal(lease.Metadata)
149
- if len(metadataJSON) > 0 {
150
- var meta types.ParsedMetadata
151
- if err := json.Unmarshal(metadataJSON, &meta); err == nil {
152
- parsedMeta = &meta
153
- }
154
- }
155
-
144
var firstSeen time.Time
145
if existing, exists := lm.leases[identityID]; exists {
146
firstSeen = existing.FirstSeen
@@ -162,11 +150,10 @@ func (lm *LeaseManager) UpdateLease(lease *Lease) bool {
150
}
151
152
lm.leases[identityID] = &LeaseEntry{
165
- Lease: lease,
166
- Expires: lease.Expires,
167
- LastSeen: time.Now(),
168
- FirstSeen: firstSeen,
169
- ParsedMetadata: parsedMeta,
153
+ Lease: lease,
154
+ Expires: lease.Expires,
155
+ LastSeen: time.Now(),
156
+ FirstSeen: firstSeen,
157
}
158
159
return true
types/api.go
-1
@@ -1,4 +1,3 @@
1
-//revive:disable:var-naming
1
package types
2
3
import "encoding/json"
types/metadata.go
-13
@@ -1,7 +1,3 @@
1
-// Package types defines all API request/response types and path constants
2
-// for the Portal relay server and SDK.
3
-//
4
-//revive:disable-next-line:var-naming
1
package types
2
3
// Metadata holds service metadata for a lease.
@@ -13,15 +9,6 @@ type Metadata struct {
9
Hide bool `json:"hide,omitempty"`
10
}
11
16
-// ParsedMetadata holds struct-parsed metadata for better access.
17
-type ParsedMetadata struct {
18
- Description string `json:"description"`
19
- Thumbnail string `json:"thumbnail"`
20
- Owner string `json:"owner"`
21
- Tags []string `json:"tags"`
22
- Hide bool `json:"hide"`
23
-}
24
-
12
// MetadataOption configures Metadata.
13
type MetadataOption func(*Metadata)
14
types/netutil.go
-1
@@ -1,4 +1,3 @@
1
-//nolint:revive // Package name is intentionally aligned with the existing module-wide convention.
1
package types
2
3
import (
types/netutil_test.go
-1
@@ -1,4 +1,3 @@
1
-//revive:disable:var-naming
1
package types
2
3
import (