diff --git a/.golangci.yml b/.golangci.yml index bea931b..7ac922c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,14 +12,13 @@ linters-settings: - performance - style govet: - check-shadowing: true + shadow: true disable: - fieldalignment # too strict nolintlint: require-explanation: false - require-specific: false - + require-specific: true linters: disable-all: true enable: @@ -29,22 +28,22 @@ linters: # it can be re-enabled. # https://github.com/OpenPeeDeeP/depguard#example-configs # - depguard + - copyloopvar - dogsled # - dupl - errcheck - - exportloopref - exhaustive - goconst - gocritic - gofmt - goimports - - gomnd - gocyclo - gosec - gosimple - govet - ineffassign - misspell + - mnd - nolintlint - nakedret - prealloc @@ -70,4 +69,4 @@ issues: run: issues-exit-code: 1 - timeout: 5m + timeout: "5m" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd09558..f263848 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/golangci/golangci-lint - rev: v1.54.2 + rev: v1.56.2 hooks: - id: golangci-lint diff --git a/.vscode/settings.json b/.vscode/settings.json index 081e421..8028cde 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "bodyclose", "cmds", "cobrass", + "copyloopvar", "coverpkg", "coverprofile", "cubiest", @@ -17,7 +18,6 @@ "dupl", "errcheck", "exportloopref", - "extendio", "fieldalignment", "GOARCH", "goconst", @@ -39,6 +39,7 @@ "linters", "mattn", "nakedret", + "natefinch", "nefilim", "nicksnyder", "nolint", diff --git a/go.mod b/go.mod index c743ab9..ec97dbb 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/onsi/gomega v1.34.2 github.com/pkg/errors v0.9.1 github.com/samber/lo v1.47.0 - github.com/snivilised/extendio v0.7.0 github.com/snivilised/li18ngo v0.1.7 github.com/snivilised/nefilim v0.1.4 github.com/spf13/cobra v1.8.1 @@ -16,7 +15,6 @@ require ( ) require ( - github.com/avfs/avfs v0.33.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -42,7 +40,7 @@ require ( github.com/natefinch/lumberjack v2.0.0+incompatible github.com/nicksnyder/go-i18n/v2 v2.4.1 github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/snivilised/cobrass v0.4.5 + github.com/snivilised/cobrass v0.5.0 github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index cc192e0..b7f5ed4 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/avfs/avfs v0.33.0 h1:5WQXbUbr6VS7aani39ZN2Vrd/s3wLnyih1Sc4ExWTxs= -github.com/avfs/avfs v0.33.0/go.mod h1:Q59flcFRYe9KYkNMfrLUJney3yeKGQpcWRyxsDBW7vI= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cubiest/jibberjabber v1.0.1 h1:JxKC9EZcdw8azEbyWaNj62ppPMkbFJBf2ayPY1vBeDI= github.com/cubiest/jibberjabber v1.0.1/go.mod h1:Ovt9ZAmzAgwQ8cWgvZ1se9oaGYzjHrlAXKM3NOzlQOs= @@ -34,8 +32,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -49,8 +45,6 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nicksnyder/go-i18n/v2 v2.4.1 h1:zwzjtX4uYyiaU02K5Ia3zSkpJZrByARkRB4V3YPrr0g= @@ -84,14 +78,10 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc= github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU= -github.com/snivilised/cobrass v0.4.5 h1:NeU/NwuOuJzotqa4JwnqGqbV1fs1SjB6GF53sXFOSGU= -github.com/snivilised/cobrass v0.4.5/go.mod h1:hGVu/zjWVG3tRKo3P0tjelm5S44vMTa/w29ygnvi+lY= -github.com/snivilised/extendio v0.7.0 h1:MY6w9qCK5wVEvP2WpMT5ywJwpDJe97WHDGuwrsTLpek= -github.com/snivilised/extendio v0.7.0/go.mod h1:l8MwJOy9ojMQYJrSKRbQS3WfDylevnRtBp/zwAmFEKc= +github.com/snivilised/cobrass v0.5.0 h1:mjoxyO2e17d7vPRHm9s0QrfRvL2ybGs0HzuQSngyxnQ= +github.com/snivilised/cobrass v0.5.0/go.mod h1:nm1jWE7F6i5R8eRlnWv3mzLFjutXIZs2vo5At5RS+TY= github.com/snivilised/li18ngo v0.1.7 h1:XRYpmP7jSAxzRyg5WH0PViFb9ycWGFcDkQQqd2GsjzQ= github.com/snivilised/li18ngo v0.1.7/go.mod h1:NVOexqt/aIhnenNPQDqbJchLNte92io87j5o2l+HNqs= -github.com/snivilised/lorax v0.5.2 h1:iReIJl63tydiPSSD0YzsNQFX1CctmvMkYx0aSxoZJKo= -github.com/snivilised/lorax v0.5.2/go.mod h1:7H1JPgSn4h4p8NSqfl64raacYefdm/FiFkfcZ51PVHY= github.com/snivilised/nefilim v0.1.4 h1:bhiENDl/T6ZQO146eF8UnxtXLQenSzEyjwuTeWScImw= github.com/snivilised/nefilim v0.1.4/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= @@ -121,14 +111,12 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.uber.org/zap/exp v0.2.0 h1:FtGenNNeCATRB3CmB/yEUnjEFeJWpB/pMcy7e2bKPYs= -go.uber.org/zap/exp v0.2.0/go.mod h1:t0gqAIdh1MfKv9EwN/dLwfZnJxe9ITAZN78HEWPFWDQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/src/app/command/bootstrap.go b/src/app/command/bootstrap.go index 517abf3..858e0d0 100644 --- a/src/app/command/bootstrap.go +++ b/src/app/command/bootstrap.go @@ -9,7 +9,7 @@ import ( "github.com/snivilised/arcadia/src/locale" "github.com/snivilised/cobrass/src/assistant" "github.com/snivilised/cobrass/src/assistant/configuration" - ci18n "github.com/snivilised/cobrass/src/assistant/i18n" + ci18n "github.com/snivilised/cobrass/src/assistant/locale" "github.com/snivilised/li18ngo" "github.com/spf13/cobra" "github.com/spf13/pflag" diff --git a/src/app/command/root-cmd_test.go b/src/app/command/root-cmd_test.go index 7a8abdc..0070085 100644 --- a/src/app/command/root-cmd_test.go +++ b/src/app/command/root-cmd_test.go @@ -6,7 +6,7 @@ import ( "github.com/snivilised/arcadia/src/app/command" "github.com/snivilised/arcadia/src/internal/helpers" - "github.com/snivilised/extendio/xfs/utils" + nef "github.com/snivilised/nefilim" ) var _ = Describe("RootCmd", Ordered, func() { @@ -18,7 +18,8 @@ var _ = Describe("RootCmd", Ordered, func() { BeforeAll(func() { repo = helpers.Repo("") l10nPath = helpers.Path(repo, "test/data/l10n") - Expect(utils.FolderExists(l10nPath)).To(BeTrue()) + fS := nef.NewUniversalABS() + Expect(fS.DirectoryExists(l10nPath)).To(BeTrue()) }) It("🧪 should: execute", func() { diff --git a/src/app/command/widget-cmd.go b/src/app/command/widget-cmd.go index 05304cf..d10c785 100644 --- a/src/app/command/widget-cmd.go +++ b/src/app/command/widget-cmd.go @@ -6,11 +6,10 @@ import ( "strings" "github.com/snivilised/cobrass/src/assistant" + "github.com/snivilised/li18ngo" "github.com/spf13/cobra" "github.com/spf13/pflag" - xi18n "github.com/snivilised/extendio/i18n" - "github.com/snivilised/arcadia/src/app/domain" "github.com/snivilised/arcadia/src/locale" ) @@ -27,8 +26,8 @@ func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cob // widgetCommand := &cobra.Command{ Use: "widget", - Short: xi18n.Text(locale.WidgetCmdShortDescTemplData{}), - Long: xi18n.Text(locale.WidgetCmdLongDescTemplData{}), + Short: li18ngo.Text(locale.WidgetCmdShortDescTemplData{}), + Long: li18ngo.Text(locale.WidgetCmdLongDescTemplData{}), RunE: func(cmd *cobra.Command, args []string) error { var appErr error diff --git a/src/app/command/widget_cmd_test.go b/src/app/command/widget_cmd_test.go index cb6d87b..952f5ff 100644 --- a/src/app/command/widget_cmd_test.go +++ b/src/app/command/widget_cmd_test.go @@ -10,10 +10,10 @@ import ( "github.com/snivilised/arcadia/src/app/command" "github.com/snivilised/arcadia/src/internal/helpers" "github.com/snivilised/arcadia/src/locale" - xi18n "github.com/snivilised/extendio/i18n" - "github.com/snivilised/extendio/xfs/utils" + "github.com/snivilised/li18ngo" + nef "github.com/snivilised/nefilim" - ci18n "github.com/snivilised/cobrass/src/assistant/i18n" + ci18n "github.com/snivilised/cobrass/src/assistant/locale" ) var _ = Describe("WidgetCmd", Ordered, func() { @@ -27,22 +27,22 @@ var _ = Describe("WidgetCmd", Ordered, func() { BeforeAll(func() { repo = helpers.Repo("") l10nPath = helpers.Path(repo, "test/data/l10n") - Expect(utils.FolderExists(l10nPath)).To(BeTrue(), + fS := nef.NewUniversalABS() + Expect(fS.DirectoryExists(l10nPath)).To(BeTrue(), fmt.Sprintf("💥 l10Path: '%v' does not exist", l10nPath), ) }) BeforeEach(func() { - xi18n.ResetTx() - err := xi18n.Use(func(uo *xi18n.UseOptions) { - uo.From = xi18n.LoadFrom{ + err := li18ngo.Use(func(uo *li18ngo.UseOptions) { + uo.From = li18ngo.LoadFrom{ Path: l10nPath, - Sources: xi18n.TranslationFiles{ - locale.ArcadiaSourceID: xi18n.TranslationSource{ + Sources: li18ngo.TranslationFiles{ + locale.ArcadiaSourceID: li18ngo.TranslationSource{ Name: "pixa", }, - ci18n.CobrassSourceID: xi18n.TranslationSource{ + ci18n.CobrassSourceID: li18ngo.TranslationSource{ Name: "cobrass", }, }, diff --git a/src/internal/log/log-defs.go b/src/internal/log/log-defs.go index f13629b..8192c6e 100644 --- a/src/internal/log/log-defs.go +++ b/src/internal/log/log-defs.go @@ -1,7 +1,6 @@ package log import ( - "github.com/snivilised/extendio/xfs/utils" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -24,8 +23,6 @@ type Logger interface { Sync() error } -type Ref utils.RoProp[Logger] - type Rotation struct { Filename string MaxSizeInMb int diff --git a/src/internal/log/new-logger.go b/src/internal/log/new-logger.go index 8ec332e..7d07792 100644 --- a/src/internal/log/new-logger.go +++ b/src/internal/log/new-logger.go @@ -1,39 +1,35 @@ package log import ( + "fmt" + "github.com/natefinch/lumberjack" - "github.com/samber/lo" - "github.com/snivilised/extendio/xfs/utils" "go.uber.org/zap" "go.uber.org/zap/zapcore" - - "github.com/snivilised/extendio/i18n" ) -func NewLogger(info *LoggerInfo) Ref { - return utils.NewRoProp(lo.TernaryF(info.Enabled, - func() Logger { - if info.Path == "" { - panic(i18n.NewInvalidConfigEntryError(info.Path, "-")) - } +func NewLogger(info *LoggerInfo) (Logger, error) { + if !info.Enabled { + return zap.NewNop(), nil + } - ws := zapcore.AddSync(&lumberjack.Logger{ - Filename: info.Path, - MaxSize: info.Rotation.MaxSizeInMb, - MaxBackups: info.Rotation.MaxNoOfBackups, - MaxAge: info.Rotation.MaxAgeInDays, - }) - config := zap.NewProductionEncoderConfig() - config.EncodeTime = zapcore.TimeEncoderOfLayout(info.TimeStampFormat) - core := zapcore.NewCore( - zapcore.NewJSONEncoder(config), - ws, - info.Level, - ) + if info.Path == "" { + return nil, fmt.Errorf("invalid config, value: %q", info.Path) + } - return zap.New(core) - }, func() Logger { - return zap.NewNop() - }), + ws := zapcore.AddSync(&lumberjack.Logger{ + Filename: info.Path, + MaxSize: info.Rotation.MaxSizeInMb, + MaxBackups: info.Rotation.MaxNoOfBackups, + MaxAge: info.Rotation.MaxAgeInDays, + }) + config := zap.NewProductionEncoderConfig() + config.EncodeTime = zapcore.TimeEncoderOfLayout(info.TimeStampFormat) + core := zapcore.NewCore( + zapcore.NewJSONEncoder(config), + ws, + info.Level, ) + + return zap.New(core), nil } diff --git a/src/locale/messages.go b/src/locale/messages.go index a6552da..2145f30 100644 --- a/src/locale/messages.go +++ b/src/locale/messages.go @@ -9,7 +9,7 @@ import ( // FooBarTemplData - TODO: this is a none existent error that should be // replaced by the client. Its just defined here to illustrate the pattern -// that should be used to implement i18n with extendio. Also note, +// that should be used to implement i18n with li18ngo. Also note, // that this message has been removed from the translation files, so // it is not useable at run time. type FooBarTemplData struct {