Linter fixes (error handling, unused constants, raw strings)

This commit is contained in:
comp500
2023-03-10 17:06:48 +00:00
parent da04eb7f13
commit aeae76a569
9 changed files with 30 additions and 19 deletions

View File

@@ -56,6 +56,10 @@ func init() {
_ = viper.BindPFlag("meta-folder-base", rootCmd.PersistentFlags().Lookup("meta-folder-base"))
defaultCacheDir, err := core.GetPackwizCache()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
rootCmd.PersistentFlags().String("cache", defaultCacheDir, "The directory where packwiz will cache downloaded mods")
_ = viper.BindPFlag("cache.directory", rootCmd.PersistentFlags().Lookup("cache"))

View File

@@ -58,7 +58,10 @@ var serveCmd = &cobra.Command{
}
indexPageBuf := new(bytes.Buffer)
t.Execute(indexPageBuf, struct{ Port string }{Port: port})
err = t.Execute(indexPageBuf, struct{ Port string }{Port: port})
if err != nil {
panic(fmt.Errorf("failed to compile index page template: %w", err))
}
// Force-disable no-internal-hashes mode (equiv to --build flag in refresh) for serving over HTTP
if viper.GetBool("no-internal-hashes") {