diff --git a/internal/update/update.go b/internal/update/update.go index 0ddd13f..d08400c 100644 --- a/internal/update/update.go +++ b/internal/update/update.go @@ -3,6 +3,7 @@ package update import ( "errors" "spotify/internal" + "strings" "github.com/blang/semver" "github.com/rhysd/go-github-selfupdate/selfupdate" @@ -24,7 +25,7 @@ func NewCommand() *cobra.Command { return errors.New(internal.ErrAlreadyUpToDate) } - current, err := semver.Parse(cmd.Root().Version) + current, err := parseVersion(cmd) if err != nil { return err } @@ -41,7 +42,7 @@ func NewCommand() *cobra.Command { } func IsUpdated(cmd *cobra.Command) (bool, error) { - current, err := semver.Parse(cmd.Root().Version) + current, err := parseVersion(cmd) if err != nil { return true, err } @@ -54,3 +55,8 @@ func IsUpdated(cmd *cobra.Command) (bool, error) { isUpdated := !found || current.Equals(latest.Version) return isUpdated, nil } + +func parseVersion(cmd *cobra.Command) (semver.Version, error) { + version := strings.TrimPrefix(cmd.Root().Version, "v") + return semver.Parse(version) +}