Skip to content

Commit

Permalink
fix issue reported by golint
Browse files Browse the repository at this point in the history
  • Loading branch information
tok-kkk committed Aug 12, 2019
1 parent 5b71f70 commit 4d4e711
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 120 deletions.
2 changes: 1 addition & 1 deletion badgerdb/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var codecs = []db.Codec{
codec.JsonCodec,
codec.JSONCodec,
codec.GobCodec,
}

Expand Down
68 changes: 0 additions & 68 deletions cache/mudb.go

This file was deleted.

1 change: 0 additions & 1 deletion cache/mudb_test.go

This file was deleted.

8 changes: 5 additions & 3 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"encoding/json"
)

var JsonCodec jsonCodec
// JSONCodec is a JSON implementation of the `db.Codec`.
var JSONCodec jsonCodec

// jsonCodec is a json implementation of the `db.Codec`. It encodes and decodes
// data using the json standard.
// jsonCodec is a JSON implementation of the `db.Codec`. It encodes and decodes
// data using the JSON standard.
type jsonCodec struct{}

// Encode implements the `db.Codec`
Expand All @@ -26,6 +27,7 @@ func (jsonCodec) String() string {
return "json"
}

// GobCodec is a gob implementation of the `db.Codec`.
var GobCodec gobCodec

// gobCodec is a gob implementation of the `db.Codec`. It encodes and decodes
Expand Down
1 change: 0 additions & 1 deletion codec/codec_suite_test.go

This file was deleted.

1 change: 0 additions & 1 deletion codec/codec_test.go

This file was deleted.

7 changes: 5 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type Codec interface {
Decode(data []byte, value interface{}) error
}

// Table is a sql-like table for storing key-value pairs. It requires the key
// to be a non-empty string and the value has the type which can be marshaled
// and unmarshaled by the used Codec.
type Table interface {

// Insert writes the key-value into the Table.
Expand All @@ -51,9 +54,9 @@ type Table interface {
Iterator() (Iterator, error)
}

// DB for storing key-value tuples. The key must be a string and the value must
// be a byte slice.
// DB is able to add new table and does operations on certain table by its name.
type DB interface {

// Creates a new table in the DB with given name and Codec.
NewTable(name string, codec Codec) (Table, error)

Expand Down
13 changes: 0 additions & 13 deletions db/db_suite_test.go

This file was deleted.

1 change: 0 additions & 1 deletion db/db_test.go

This file was deleted.

39 changes: 16 additions & 23 deletions kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,37 @@ var (
)

type (
// TODO: Comment!
// Table is a sql-like table for storing key-value pairs. It requires the key
// to be a non-empty string and the value has the type which can be marshaled
// and unmarshaled by the used Codec.
Table = db.Table

// TODO: Comment!
// DB is able to add new table and does operations on certain table by its name.
DB = db.DB

// TODO: Comment!
// Codec can encode and decode between arbitrary data object and bytes.
Codec = db.Codec

// TODO: Comment!
Iterator = db.Codec
// Iterator is used to iterate through the data in the store.
Iterator = db.Iterator
)

// In-memory implementation of the DB and table
var (

// TODO: Comment!
// NewTable returns a in-memory implementation of the Table interface.
NewMemTable = memdb.NewTable

// NewMemDB returns a key-value database that is implemented in-memory. This
// implementation is fast, but does not store data on-disk. A time-to-live can
// be used to automatically delete key-value tuples after they have been in the
// database for more than a specific duration. A time-to-live of zero will keep
// key-value tuples until they are explicitly deleted. It is safe for concurrent
// use.
// implementation is fast, but does not store data on-disk. It is safe for
// concurrent use.
NewMemDB = memdb.New
)

// BadgerDB implementation of the DB and table.
var (
// TODO: Comment!
// NewBadgerTable returns a Table with a badgerDB implementation. It is safe for
// concurrent use.
NewBadgerTable = badgerdb.NewTable

// NewBadgerDB returns a key-value database that is implemented using
Expand All @@ -71,7 +71,8 @@ var (

// LevelDB implementation of the DB and table.
var (
// TODO: Comment!
// NewBadgerTable returns a Table with a leveldb implementation. It is safe for
// concurrent use.
NewLevelTable = leveldb.NewTable

// NewLevelDB returns a key-value database that is implemented using
Expand All @@ -80,20 +81,12 @@ var (
)

var (
// JsonCodec is a json codec that marshals and unmarshals values using the
// JSONCodec is a json codec that marshals and unmarshals values using the
// standard Golang JSON marshalers. For more information, see
// https://golang.org/pkg/encoding/json.
JsonCodec = codec.JsonCodec
JSONCodec = codec.JSONCodec

// GobCodec is a gob codec that encodes and decodes values using gob. For
// more information, see https://golang.org/pkg/encoding/gob.
GobCodec = codec.GobCodec
)

// var (
// // NewTTLCache returns a cache that wraps an underlying store. Keys that have
// // no been accessed for the specified duration will be automatically deleted
// // from the underlying store. It is safe for concurrent use, as long as the
// // underlying store is also safe for concurrent use.
// NewTTLCache = cache.NewTTL
// )
2 changes: 1 addition & 1 deletion leveldb/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var codecs = []db.Codec{
codec.JsonCodec,
codec.JSONCodec,
codec.GobCodec,
}

Expand Down
2 changes: 1 addition & 1 deletion memdb/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type table struct {
codec db.Codec
}

// New returns a new table.
// NewTable returns a new table using given Codec.
func NewTable(codec db.Codec) db.Table {
return &table{
mu: new(sync.RWMutex),
Expand Down
2 changes: 1 addition & 1 deletion memdb/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

var codecs = []db.Codec{
codec.JsonCodec,
codec.JSONCodec,
codec.GobCodec,
}

Expand Down
6 changes: 3 additions & 3 deletions testutil/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

var Ran = rand.New(rand.NewSource(time.Now().Unix()))
var ran = rand.New(rand.NewSource(time.Now().Unix()))

// TestStruct is a struct which includes some commonly used types.
type TestStruct struct {
Expand All @@ -21,7 +21,7 @@ type TestStruct struct {
// RandomTestStruct returns a random `TestStruct`
func RandomTestStruct() TestStruct {
t := reflect.TypeOf(TestStruct{})
value, ok := quick.Value(t, Ran)
value, ok := quick.Value(t, ran)
if !ok {
panic("cannot create random test struct")
}
Expand Down Expand Up @@ -49,7 +49,7 @@ func RandomNonDupStrings(i int) []string {

for len(res) < cap {
t := reflect.TypeOf("")
value, ok := quick.Value(t, Ran)
value, ok := quick.Value(t, ran)
if !ok {
panic("cannot create random test struct")
}
Expand Down

0 comments on commit 4d4e711

Please sign in to comment.