golang的私有化定制自动更新插件
编辑 | blame | 历史 | 原始文档

goupdate

  • golang的私有化定制自动更新插件
  • Goupdate 是用 Go 语言开发的工具,能够自动从 GitHub 和 Gitee 下载最新的发布版本,并更新本地程序。

本程序是基于 https://github.com/tj/go-update 进行的分支,进行了额外功能的增强。33333

更新 github

package main

import (
	"github.com/zan8in/gologger"
	"github.com/zan8in/goupdate"
	"github.com/zan8in/goupdate/stores/github"
)

func main() {

	owner := "zan8in"
	repo := "afrog"
	version := "2.8.1"

	if result, err := github.Update(owner, repo, version); err != nil {
		gologger.Error().Msg(err.Error())
	} else {
		if result.Status == 2 {
			gologger.Info().Msgf("%s %s", repo, goupdate.LatestVersionTips)
		} else {
			gologger.Info().Msgf("Successfully updated to %s %s\n", repo, result.LatestVersion)
		}
	}

}

更新 gitee

package main

import (
	"github.com/zan8in/gologger"
	"github.com/zan8in/goupdate"
	"github.com/zan8in/goupdate/stores/gitee"
)

func main() {

	owner := "zanbin"
	repo := "afrog"
	version := "2.8.9"

	if result, err := gitee.Update(owner, repo, version); err != nil {
		gologger.Error().Msg(err.Error())
	} else {
		if result.Status == 2 {
			gologger.Info().Msgf("%s %s", repo, goupdate.LatestVersionTips)
		} else {
			gologger.Info().Msgf("Successfully updated to %s %s\n", repo, result.LatestVersion)
		}
	}

}

编辑 | blame | 历史 | 原始文档
MIT License

Copyright (c) 2023 zan8in

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
README 1 KB