kubo/plugin/plugins/fxtest/fxtest.go
Marcin Rataj 4f4dac9564 chore: fix all golangci-lint staticcheck issues
align kubo with unified golang ci linter from IPDX and
rules used in boxo and other go packages

addressed lint rules:
- ST1000: added package comments
- ST1020, ST1021, ST1022: fixed function/method comments
- QF1001: applied De Morgan's law
- QF1003: converted if-else chains to tagged switches
- QF1004: replaced strings.Replace with strings.ReplaceAll
- QF1008: simplified embedded struct field selectors
- unconvert: removed unnecessary type conversions
- usestdlibvars: used stdlib constants instead of literals

disabled errcheck linter in .golangci.yml
2025-08-20 02:07:42 +02:00

46 lines
1002 B
Go

// Package fxtest provides a test plugin for the fx dependency injection framework.
package fxtest
import (
"os"
logging "github.com/ipfs/go-log/v2"
"github.com/ipfs/kubo/core"
"github.com/ipfs/kubo/plugin"
"go.uber.org/fx"
)
var log = logging.Logger("fxtestplugin")
var Plugins = []plugin.Plugin{
&fxtestPlugin{},
}
// fxtestPlugin is used for testing the fx plugin.
// It merely adds an fx option that logs a debug statement, so we can verify that it works in tests.
type fxtestPlugin struct{}
var _ plugin.PluginFx = (*fxtestPlugin)(nil)
func (p *fxtestPlugin) Name() string {
return "fx-test"
}
func (p *fxtestPlugin) Version() string {
return "0.1.0"
}
func (p *fxtestPlugin) Init(env *plugin.Environment) error {
return nil
}
func (p *fxtestPlugin) Options(info core.FXNodeInfo) ([]fx.Option, error) {
opts := info.FXOptions
if os.Getenv("TEST_FX_PLUGIN") != "" {
opts = append(opts, fx.Invoke(func() {
log.Debug("invoked test fx function")
}))
}
return opts, nil
}