Skip to content

Commit aa8c51c

Browse files
committed
chore(linter): run go fmt on the repo
1 parent 5eb141c commit aa8c51c

18 files changed

+87
-70
lines changed

.golangci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
run:
2-
tests: false
2+
skip-dirs:
3+
skip-files:
34

45
linters-settings:
56
lll:
@@ -8,14 +9,13 @@ linters-settings:
89
linters:
910
disable-all: true
1011
enable:
11-
# - errcheck
12-
# - ineffassign
13-
# - gas
12+
# - errcheck
13+
# - ineffassign
14+
# - gas
1415
- gofmt
15-
# - golint
16-
- gosimple
17-
- govet
18-
- lll
19-
# - varcheck
20-
# - unused
21-
# - gosec
16+
# - gosimple
17+
# - govet
18+
# - lll
19+
# - unused
20+
# - staticcheck
21+
- goimports

db.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,8 @@ func (db *DB) doWrites(lc *z.Closer) {
945945

946946
// batchSet applies a list of badger.Entry. If a request level error occurs it
947947
// will be returned.
948-
// Check(kv.BatchSet(entries))
948+
//
949+
// Check(kv.BatchSet(entries))
949950
func (db *DB) batchSet(entries []*Entry) error {
950951
req, err := db.sendToWriteCh(entries)
951952
if err != nil {
@@ -958,9 +959,10 @@ func (db *DB) batchSet(entries []*Entry) error {
958959
// batchSetAsync is the asynchronous version of batchSet. It accepts a callback
959960
// function which is called when all the sets are complete. If a request level
960961
// error occurs, it will be passed back via the callback.
961-
// err := kv.BatchSetAsync(entries, func(err error)) {
962-
// Check(err)
963-
// }
962+
//
963+
// err := kv.BatchSetAsync(entries, func(err error)) {
964+
// Check(err)
965+
// }
964966
func (db *DB) batchSetAsync(entries []*Entry, f func(error)) error {
965967
req, err := db.sendToWriteCh(entries)
966968
if err != nil {
@@ -1719,16 +1721,16 @@ func (db *DB) dropAll() (func(), error) {
17191721
}
17201722

17211723
// DropPrefix would drop all the keys with the provided prefix. It does this in the following way:
1722-
// - Stop accepting new writes.
1723-
// - Stop memtable flushes before acquiring lock. Because we're acquring lock here
1724-
// and memtable flush stalls for lock, which leads to deadlock
1725-
// - Flush out all memtables, skipping over keys with the given prefix, Kp.
1726-
// - Write out the value log header to memtables when flushing, so we don't accidentally bring Kp
1727-
// back after a restart.
1728-
// - Stop compaction.
1729-
// - Compact L0->L1, skipping over Kp.
1730-
// - Compact rest of the levels, Li->Li, picking tables which have Kp.
1731-
// - Resume memtable flushes, compactions and writes.
1724+
// - Stop accepting new writes.
1725+
// - Stop memtable flushes before acquiring lock. Because we're acquring lock here
1726+
// and memtable flush stalls for lock, which leads to deadlock
1727+
// - Flush out all memtables, skipping over keys with the given prefix, Kp.
1728+
// - Write out the value log header to memtables when flushing, so we don't accidentally bring Kp
1729+
// back after a restart.
1730+
// - Stop compaction.
1731+
// - Compact L0->L1, skipping over Kp.
1732+
// - Compact rest of the levels, Li->Li, picking tables which have Kp.
1733+
// - Resume memtable flushes, compactions and writes.
17321734
func (db *DB) DropPrefix(prefixes ...[]byte) error {
17331735
if len(prefixes) == 0 {
17341736
return nil

db2_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,17 @@ func TestL0GCBug(t *testing.T) {
657657
//
658658
// The test has 3 steps
659659
// Step 1 - Create badger data. It is necessary that the value size is
660-
// greater than valuethreshold. The value log file size after
661-
// this step is around 170 bytes.
660+
//
661+
// greater than valuethreshold. The value log file size after
662+
// this step is around 170 bytes.
663+
//
662664
// Step 2 - Re-open the same badger and simulate a crash. The value log file
663-
// size after this crash is around 2 GB (we increase the file size to mmap it).
665+
//
666+
// size after this crash is around 2 GB (we increase the file size to mmap it).
667+
//
664668
// Step 3 - Re-open the same badger. We should be able to read all the data
665-
// inserted in the first step.
669+
//
670+
// inserted in the first step.
666671
func TestWindowsDataLoss(t *testing.T) {
667672
if runtime.GOOS != "windows" {
668673
t.Skip("The test is only for Windows.")
@@ -995,7 +1000,7 @@ func TestKeyCount(t *testing.T) {
9951000
}()
9961001

9971002
write := func(kvs *pb.KVList) error {
998-
buf := z.NewBuffer(1 << 20, "test")
1003+
buf := z.NewBuffer(1<<20, "test")
9991004
defer buf.Release()
10001005

10011006
for _, kv := range kvs.Kv {

dir_plan9.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ func syncDir(dir string) error {
123123
// Opening an exclusive-use file returns an error.
124124
// The expected error strings are:
125125
//
126-
// - "open/create -- file is locked" (cwfs, kfs)
127-
// - "exclusive lock" (fossil)
128-
// - "exclusive use file already open" (ramfs)
126+
// - "open/create -- file is locked" (cwfs, kfs)
127+
// - "exclusive lock" (fossil)
128+
// - "exclusive use file already open" (ramfs)
129129
//
130130
// See https://github.com/golang/go/blob/go1.15rc1/src/cmd/go/internal/lockedfile/lockedfile_plan9.go#L16
131131
var lockedErrStrings = [...]string{

dir_unix.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !windows && !plan9
12
// +build !windows,!plan9
23

34
/*

dir_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
/*

doc.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ hence reducing both write amplification and the size of the LSM tree. This
1010
allows LSM tree to be served entirely from RAM, while the values are served
1111
from SSD.
1212
13-
14-
Usage
13+
# Usage
1514
1615
Badger has the following main types: DB, Txn, Item and Iterator. DB contains
1716
keys that are associated with values. It must be opened with the appropriate

iterator_test.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,16 @@ func TestIteratorReadOnlyWithNoData(t *testing.T) {
324324
// pkg: github.com/dgraph-io/badger
325325
// BenchmarkIteratePrefixSingleKey/Key_lookups-4 10000 365539 ns/op
326326
// --- BENCH: BenchmarkIteratePrefixSingleKey/Key_lookups-4
327-
// iterator_test.go:147: Inner b.N: 1
328-
// iterator_test.go:147: Inner b.N: 100
329-
// iterator_test.go:147: Inner b.N: 10000
327+
//
328+
// iterator_test.go:147: Inner b.N: 1
329+
// iterator_test.go:147: Inner b.N: 100
330+
// iterator_test.go:147: Inner b.N: 10000
331+
//
330332
// --- BENCH: BenchmarkIteratePrefixSingleKey
331-
// iterator_test.go:143: LSM files: 79
332-
// iterator_test.go:145: Outer b.N: 1
333+
//
334+
// iterator_test.go:143: LSM files: 79
335+
// iterator_test.go:145: Outer b.N: 1
336+
//
333337
// PASS
334338
// ok github.com/dgraph-io/badger 41.586s
335339
//
@@ -339,12 +343,16 @@ func TestIteratorReadOnlyWithNoData(t *testing.T) {
339343
// pkg: github.com/dgraph-io/badger
340344
// BenchmarkIteratePrefixSingleKey/Key_lookups-4 10000 460924 ns/op
341345
// --- BENCH: BenchmarkIteratePrefixSingleKey/Key_lookups-4
342-
// iterator_test.go:147: Inner b.N: 1
343-
// iterator_test.go:147: Inner b.N: 100
344-
// iterator_test.go:147: Inner b.N: 10000
346+
//
347+
// iterator_test.go:147: Inner b.N: 1
348+
// iterator_test.go:147: Inner b.N: 100
349+
// iterator_test.go:147: Inner b.N: 10000
350+
//
345351
// --- BENCH: BenchmarkIteratePrefixSingleKey
346-
// iterator_test.go:143: LSM files: 83
347-
// iterator_test.go:145: Outer b.N: 1
352+
//
353+
// iterator_test.go:143: LSM files: 83
354+
// iterator_test.go:145: Outer b.N: 1
355+
//
348356
// PASS
349357
// ok github.com/dgraph-io/badger 41.836s
350358
//

options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ func (opt Options) WithValueThreshold(val int64) Options {
514514
// and only 1 percent in vlog. The value threshold will be dynamically updated within the range of
515515
// [ValueThreshold, Options.maxValueThreshold]
516516
//
517-
// Say VLogPercentile with 1.0 means threshold will eventually set to Options.maxValueThreshold
517+
// # Say VLogPercentile with 1.0 means threshold will eventually set to Options.maxValueThreshold
518518
//
519519
// The default value of VLogPercentile is 0.0.
520520
func (opt Options) WithVLogPercentile(t float64) Options {

publisher.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import (
2727
)
2828

2929
type subscriber struct {
30-
id uint64
30+
id uint64
3131
matches []pb.Match
3232
sendCh chan *pb.KVList
3333
subCloser *z.Closer
3434
// this will be atomic pointer which will be used to
3535
// track whether the subscriber is active or not
36-
active *uint64
36+
active *uint64
3737
}
3838

3939
type publisher struct {
@@ -126,8 +126,8 @@ func (p *publisher) newSubscriber(c *z.Closer, matches []pb.Match) subscriber {
126126
p.nextID++
127127
active := uint64(1)
128128
s := subscriber{
129-
active: &active,
130-
id: id,
129+
active: &active,
130+
id: id,
131131
matches: matches,
132132
sendCh: ch,
133133
subCloser: c,

0 commit comments

Comments
 (0)