mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
Fix linter issues: gochecknoinits
This commit is contained in:
parent
cceb1ebdf6
commit
0b86bbb4f5
18 changed files with 33 additions and 89 deletions
1
Makefile
1
Makefile
|
|
@ -113,6 +113,7 @@ gometalinter: require-gometalinter
|
|||
gometalinter --vendor --disable-all \
|
||||
--deadline=60s \
|
||||
--enable=deadcode \
|
||||
--enable=gochecknoinits \
|
||||
--enable=gofmt \
|
||||
--enable=goimports \
|
||||
--enable=gotype \
|
||||
|
|
|
|||
|
|
@ -37,12 +37,8 @@ type broadcaster interface {
|
|||
// TODO add at least a single "isMessage()" method.
|
||||
type Message interface{}
|
||||
|
||||
func init() {
|
||||
NopBroadcaster = &nopBroadcaster{}
|
||||
}
|
||||
|
||||
// NopBroadcaster represents a Broadcaster that doesn't do anything.
|
||||
var NopBroadcaster broadcaster
|
||||
var NopBroadcaster broadcaster = &nopBroadcaster{}
|
||||
|
||||
type nopBroadcaster struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
var checker *ctl.CheckCommand
|
||||
|
||||
func newCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
|
||||
func newCheckCommand(_ io.Reader, _, _ io.Writer) *cobra.Command {
|
||||
checker = ctl.NewCheckCommand(os.Stdin, os.Stdout, os.Stderr)
|
||||
checkCmd := &cobra.Command{
|
||||
Use: "check <path> [path2]...",
|
||||
|
|
@ -48,7 +48,3 @@ Performs a consistency check on data files.
|
|||
}
|
||||
return checkCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["check"] = newCheckCommand
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,3 @@ func newConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command
|
|||
|
||||
return confCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["config"] = newConfigCommand
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
var Exporter *ctl.ExportCommand
|
||||
|
||||
func newExportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
|
||||
func newExportCommand(_ io.Reader, _, _ io.Writer) *cobra.Command {
|
||||
Exporter = ctl.NewExportCommand(os.Stdin, os.Stdout, os.Stderr)
|
||||
exportCmd := &cobra.Command{
|
||||
Use: "export",
|
||||
|
|
@ -58,7 +58,3 @@ The file does not contain any headers.
|
|||
|
||||
return exportCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["export"] = newExportCommand
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
var generateConf *ctl.GenerateConfigCommand
|
||||
|
||||
func newGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
|
||||
func newGenerateConfigCommand(_ io.Reader, _, _ io.Writer) *cobra.Command {
|
||||
generateConf = ctl.NewGenerateConfigCommand(os.Stdin, os.Stdout, os.Stderr)
|
||||
confCmd := &cobra.Command{
|
||||
Use: "generate-config",
|
||||
|
|
@ -43,7 +43,3 @@ func newGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.
|
|||
|
||||
return confCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["generate-config"] = newGenerateConfigCommand
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,3 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM.
|
|||
|
||||
return importCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["import"] = newImportCommand
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
var inspector *ctl.InspectCommand
|
||||
|
||||
func newInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
|
||||
func newInspectCommand(_ io.Reader, _, _ io.Writer) *cobra.Command {
|
||||
inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr)
|
||||
|
||||
inspectCmd := &cobra.Command{
|
||||
|
|
@ -51,7 +51,3 @@ Inspects a data file and provides stats.
|
|||
}
|
||||
return inspectCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["inspect"] = newInspectCommand
|
||||
}
|
||||
|
|
|
|||
16
cmd/root.go
16
cmd/root.go
|
|
@ -25,10 +25,6 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// TODO maybe give this an Add method which will ensure two command
|
||||
// with same name aren't added
|
||||
var subcommandFns = map[string]func(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command{}
|
||||
|
||||
func NewRootCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command {
|
||||
productName := "Pilosa " + pilosa.Version
|
||||
if pilosa.EnterpriseEnabled {
|
||||
|
|
@ -69,9 +65,15 @@ Build Time: ` + pilosa.BuildTime + "\n",
|
|||
rc.PersistentFlags().Bool("dry-run", false, "stop before executing")
|
||||
_ = rc.PersistentFlags().MarkHidden("dry-run")
|
||||
rc.PersistentFlags().StringP("config", "c", "", "Configuration file to read from.")
|
||||
for _, subcomFn := range subcommandFns {
|
||||
rc.AddCommand(subcomFn(stdin, stdout, stderr))
|
||||
}
|
||||
|
||||
rc.AddCommand(newCheckCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newConfigCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newExportCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newGenerateConfigCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newImportCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newInspectCommand(stdin, stdout, stderr))
|
||||
rc.AddCommand(newServeCmd(stdin, stdout, stderr))
|
||||
|
||||
rc.SetOutput(stderr)
|
||||
return rc
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,3 @@ on the configured port.`,
|
|||
ctl.BuildServerFlags(serveCmd, Server)
|
||||
return serveCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
subcommandFns["server"] = newServeCmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
package b
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
|
|
@ -40,20 +39,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// kx must be >= 2
|
||||
kx = 128 //TODO benchmark tune this number if using custom key/value type(s).
|
||||
// kd must be >= 1
|
||||
kd = 128 //TODO benchmark tune this number if using custom key/value type(s).
|
||||
)
|
||||
|
||||
func init() {
|
||||
if kd < 1 {
|
||||
panic(fmt.Errorf("kd %d: out of range", kd))
|
||||
}
|
||||
|
||||
if kx < 2 {
|
||||
panic(fmt.Errorf("kx %d: out of range", kx))
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
btDPool = sync.Pool{New: func() interface{} { return &d{} }}
|
||||
btEPool = btEpool{sync.Pool{New: func() interface{} { return &enumerator{} }}}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/pilosa/pilosa/roaring"
|
||||
)
|
||||
|
||||
func init() {
|
||||
func init() { // nolint: gochecknoinits
|
||||
// Replace Bitmap constructor with B+Tree implementation
|
||||
roaring.NewFileBitmap = b.NewBTreeBitmap
|
||||
}
|
||||
|
|
|
|||
6
gc.go
6
gc.go
|
|
@ -23,12 +23,8 @@ type GCNotifier interface {
|
|||
AfterGC() <-chan struct{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
NopGCNotifier = &nopGCNotifier{}
|
||||
}
|
||||
|
||||
// NopGCNotifier represents a GCNotifier that doesn't do anything.
|
||||
var NopGCNotifier GCNotifier
|
||||
var NopGCNotifier GCNotifier = &nopGCNotifier{}
|
||||
|
||||
type nopGCNotifier struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,6 @@ import (
|
|||
"github.com/pilosa/pilosa/test"
|
||||
)
|
||||
|
||||
var defaultClient *gohttp.Client
|
||||
|
||||
func init() {
|
||||
defaultClient = http.GetHTTPClient(nil)
|
||||
|
||||
}
|
||||
|
||||
// Test distributed TopN Row count across 3 nodes.
|
||||
func TestClient_MultiNode(t *testing.T) {
|
||||
c := test.MustRunCluster(t, 3,
|
||||
|
|
@ -125,9 +118,9 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
|
||||
// Connect to each node to compare results.
|
||||
client := make([]*Client, 3)
|
||||
client[0] = MustNewClient(c[0].URL(), defaultClient)
|
||||
client[1] = MustNewClient(c[1].URL(), defaultClient)
|
||||
client[2] = MustNewClient(c[2].URL(), defaultClient)
|
||||
client[0] = MustNewClient(c[0].URL(), http.GetHTTPClient(nil))
|
||||
client[1] = MustNewClient(c[1].URL(), http.GetHTTPClient(nil))
|
||||
client[2] = MustNewClient(c[2].URL(), http.GetHTTPClient(nil))
|
||||
|
||||
topN := 4
|
||||
queryRequest := &pilosa.QueryRequest{
|
||||
|
|
@ -191,7 +184,7 @@ func TestClient_Import(t *testing.T) {
|
|||
hldr.Row("i", "f", 0)
|
||||
|
||||
// Send import request.
|
||||
c := MustNewClient(host, defaultClient)
|
||||
c := MustNewClient(host, http.GetHTTPClient(nil))
|
||||
if err := c.Import(context.Background(), "i", "f", 0, []pilosa.Bit{
|
||||
{RowID: 0, ColumnID: 1},
|
||||
{RowID: 0, ColumnID: 5},
|
||||
|
|
@ -226,7 +219,7 @@ func TestClient_ImportValue(t *testing.T) {
|
|||
}
|
||||
|
||||
// Send import request.
|
||||
c := MustNewClient(host, defaultClient)
|
||||
c := MustNewClient(host, http.GetHTTPClient(nil))
|
||||
if err := c.ImportValue(context.Background(), "i", "f", 0, []pilosa.FieldValue{
|
||||
{ColumnID: 1, Value: -10},
|
||||
{ColumnID: 2, Value: 20},
|
||||
|
|
@ -287,7 +280,7 @@ func TestClient_FragmentBlocks(t *testing.T) {
|
|||
|
||||
// Set a bit on a different shard.
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
c := MustNewClient(cmd.URL(), defaultClient)
|
||||
c := MustNewClient(cmd.URL(), http.GetHTTPClient(nil))
|
||||
blocks, err := c.FragmentBlocks(context.Background(), nil, "i", "f", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -28,12 +28,8 @@ type Logger interface {
|
|||
Debugf(format string, v ...interface{})
|
||||
}
|
||||
|
||||
func init() {
|
||||
NopLogger = &nopLogger{}
|
||||
}
|
||||
|
||||
// NopLogger represents a Logger that doesn't do anything.
|
||||
var NopLogger Logger
|
||||
var NopLogger Logger = &nopLogger{}
|
||||
|
||||
type nopLogger struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
type loggerLogger interface {
|
||||
pilosa.Logger
|
||||
Logger() *log.Logger
|
||||
|
|
@ -126,6 +122,9 @@ func NewCommand(stdin io.Reader, stdout, stderr io.Writer, opts ...CommandOption
|
|||
func (m *Command) Start() (err error) {
|
||||
defer close(m.Started)
|
||||
|
||||
// Seed random number generator
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
// SetupServer
|
||||
err = m.SetupServer()
|
||||
if err != nil {
|
||||
|
|
|
|||
6
stats.go
6
stats.go
|
|
@ -22,10 +22,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
NopStatsClient = &nopStatsClient{}
|
||||
}
|
||||
|
||||
// Expvar global expvar map.
|
||||
var Expvar = expvar.NewMap("index")
|
||||
|
||||
|
|
@ -66,7 +62,7 @@ type StatsClient interface {
|
|||
}
|
||||
|
||||
// NopStatsClient represents a client that doesn't do anything.
|
||||
var NopStatsClient StatsClient
|
||||
var NopStatsClient StatsClient = &nopStatsClient{}
|
||||
|
||||
type nopStatsClient struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ var EnterpriseEnabled = false
|
|||
var Version = "v0.0.0"
|
||||
var BuildTime = "not recorded"
|
||||
|
||||
func init() {
|
||||
// init sets the EnterpriseEnabled bool, based on the Enterprise string.
|
||||
// This is needed because bools cannot be set with ldflags.
|
||||
func init() { // nolint: gochecknoinits
|
||||
if Enterprise == "1" {
|
||||
EnterpriseEnabled = true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue