INNER CODE UNIT · Go

newVersionMsg

lucagrulla/cw · versioncheck.go:29

func newVersionMsg(currentVersion string, latestVersionChannel chan string) {
	latestVersion, ok := <-latestVersionChannel
	//if the channel is closed we failed to fetch the latest version. Ignore version message.
	if !ok {
		if latestVersion != fmt.Sprintf("v%s", currentVersion) {
			msg := fmt.Sprintf("\n\n%s - %s -> %s", color.GreenString("A new version of cw is available!"), color.YellowString(currentVersion), color.GreenString(latestVersion))
			fmt.Fprintln(os.Stderr, msg)
		}
	}
}

func versionCheckOnSigterm() {
	//only way to avoid print of the signal: interrupt message
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	<-c
	os.Exit(0)
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…