Skip to content

Commit 9283ef4

Browse files
committed
fix linting issues
1 parent 0299cd5 commit 9283ef4

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

internal/httprate/counter.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ func (c *counter) Try(key string) (bool, int, time.Time) {
5050
func (c *counter) Cleanup() {
5151
ticker := time.NewTicker(time.Second * 10)
5252
defer ticker.Stop()
53-
for {
54-
select {
55-
case <-ticker.C:
56-
c.doCleanup()
57-
}
53+
54+
for range ticker.C {
55+
c.doCleanup()
5856
}
5957
}
6058

@@ -72,6 +70,6 @@ func (c *counter) doCleanup() {
7270

7371
func counterKey(key string) uint64 {
7472
h := xxhash.New()
75-
h.WriteString(key)
73+
_, _ = h.WriteString(key)
7674
return h.Sum64()
7775
}

internal/httprate/limiter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func canonicalizeIP(ip string) string {
7777
case ':':
7878
// IPv6
7979
isIPv6 = true
80-
break
8180
}
8281
}
8382
if !isIPv6 {

main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"embed"
66
"flag"
77
"io/fs"
8-
"log"
98
"log/slog"
109
"net/http"
1110
"os"
@@ -107,9 +106,6 @@ func main() {
107106
driver = sqlite.New
108107
}
109108

110-
entries, err := Migrations.ReadDir(".")
111-
log.Printf("entries: %v", entries)
112-
113109
if err = gomigrate.Migrate(ctx, db, driver, Migrations, gomigrate.WithDirectory("server/migrations")); err != nil {
114110
slog.Error("Error while migrating database", tint.Err(err))
115111
os.Exit(1)

server/database/db.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/topi314/gomigrate"
1919
"go.opentelemetry.io/otel/attribute"
2020
"go.opentelemetry.io/otel/semconv/v1.25.0"
21-
"go.opentelemetry.io/otel/trace"
2221
_ "modernc.org/sqlite"
2322

2423
"github.com/topi314/gobin/v2/internal/timex"
@@ -55,8 +54,8 @@ func (c Config) String() string {
5554
str := fmt.Sprintf("\n Type: %s\n Debug: %t\n ExpireAfter: %s\n CleanupInterval: %s\n ",
5655
c.Type,
5756
c.Debug,
58-
c.ExpireAfter,
59-
c.CleanupInterval,
57+
time.Duration(c.ExpireAfter),
58+
time.Duration(c.CleanupInterval),
6059
)
6160
switch c.Type {
6261
case TypePostgres:
@@ -156,8 +155,7 @@ func New(ctx context.Context, cfg Config) (*DB, error) {
156155

157156
type DB struct {
158157
*sqlx.DB
159-
rand *rand.Rand
160-
tracer trace.Tracer
158+
rand *rand.Rand
161159
}
162160

163161
func (d *DB) randomString(length int) string {

server/database/documents.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (d *DB) DeleteDocumentVersion(ctx context.Context, documentID string, docum
159159
return &Document{
160160
ID: documentID,
161161
Version: documentVersion,
162-
Files: files,
162+
Files: lastDeletedFiles,
163163
}, nil
164164
}
165165

0 commit comments

Comments
 (0)