Upgrade Go version to 1.24.0 and update various dependencies, including NATS, Viper, and Go modules. Refactor error handling in configuration loading and validation processes for improved clarity and consistency.

This commit is contained in:
windyboy
2025-11-14 23:42:39 +08:00
parent 88d5922f90
commit 31839cf21f
4 changed files with 26 additions and 36 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ tasks:
desc: Upgrade go dependencies
cmds:
- echo "Upgrading go dependencies..."
- go get -u -d -v ./...
- go get -u -v ./...
- go mod tidy
install-test:
+19 -27
View File
@@ -1,6 +1,6 @@
module caatsm
go 1.23.0
go 1.24.0
require (
github.com/google/uuid v1.6.0
@@ -10,57 +10,49 @@ require (
github.com/knadh/koanf/providers/env v1.1.0
github.com/knadh/koanf/providers/file v1.2.0
github.com/knadh/koanf/v2 v2.3.0
github.com/nats-io/nats.go v1.36.0
github.com/nats-io/nats.go v1.47.0
github.com/onsi/ginkgo/v2 v2.25.1
github.com/onsi/gomega v1.38.2
github.com/spf13/viper v1.19.0
github.com/urfave/cli/v2 v2.27.4
github.com/spf13/viper v1.21.0
github.com/urfave/cli/v2 v2.27.7
go.uber.org/zap v1.27.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)
require (
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/knadh/koanf/maps v0.1.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nkeys v0.4.11 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/tools v0.36.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
golang.org/x/crypto v0.44.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.39.0 // indirect
)
+4 -6
View File
@@ -94,16 +94,14 @@ func LoadConfig() (*Config, error) {
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
if err := viper.ReadInConfig(); err != nil {
errMsg := fmt.Sprintf("error reading config file for environment '%s': %v", env, err)
// log.Error(errMsg)
return nil, fmt.Errorf(errMsg)
// log.Errorf("error reading config file for environment '%s': %v", env, err)
return nil, fmt.Errorf("error reading config file for environment '%s': %w", env, err)
}
var config Config
if err := viper.Unmarshal(&config); err != nil {
errMsg := fmt.Sprintf("unable to decode config into struct for environment '%s': %v", env, err)
// log.Error(errMsg)
return nil, fmt.Errorf(errMsg)
// log.Errorf("unable to decode config into struct for environment '%s': %v", env, err)
return nil, fmt.Errorf("unable to decode config into struct for environment '%s': %w", env, err)
}
return &config, nil
}
+2 -2
View File
@@ -100,8 +100,8 @@ func (h *SITAHeader) Validate() error {
if len(h.SendTime) != 6 {
err := "invalid send_time format"
log.Errorf("error validating send_time: %v", err)
return fmt.Errorf(err)
log.Errorf("error validating send_time: %s", err)
return fmt.Errorf("%s", err)
}
return nil
}