Fix gosec, govet, and errorlint linter errors

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-03-15 10:04:12 -07:00
parent dd31e440e6
commit fbaf79a8a0
35 changed files with 236 additions and 232 deletions

View File

@@ -43,7 +43,7 @@ func runInit(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer database.Close()
defer func() { _ = database.Close() }()
if err := db.Migrate(database); err != nil {
return err

View File

@@ -29,5 +29,5 @@ func initConfig() {
}
viper.AutomaticEnv()
viper.SetEnvPrefix("METACRYPT")
viper.ReadInConfig()
_ = viper.ReadInConfig()
}

View File

@@ -50,7 +50,7 @@ func runServer(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer database.Close()
defer func() { _ = database.Close() }()
if err := db.Migrate(database); err != nil {
return err

View File

@@ -40,7 +40,7 @@ func runSnapshot(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer database.Close()
defer func() { _ = database.Close() }()
if err := sqliteBackup(database, snapshotOutput); err != nil {
return err

View File

@@ -26,7 +26,7 @@ var (
func init() {
statusCmd.Flags().StringVar(&statusAddr, "addr", "", "server address (e.g., https://localhost:8443)")
statusCmd.Flags().StringVar(&statusCACert, "ca-cert", "", "path to CA certificate for TLS verification")
statusCmd.MarkFlagRequired("addr")
_ = statusCmd.MarkFlagRequired("addr")
rootCmd.AddCommand(statusCmd)
}
@@ -34,7 +34,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
tlsCfg := &tls.Config{MinVersion: tls.VersionTLS12}
if statusCACert != "" {
pem, err := os.ReadFile(statusCACert)
pem, err := os.ReadFile(statusCACert) //nolint:gosec
if err != nil {
return fmt.Errorf("read CA cert: %w", err)
}
@@ -53,7 +53,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
var status struct {
State string `json:"state"`