Build self-updating Go programs

API Reference Apache V2 License

selfupdate: Build self-updating Go programs

NOTE: Original work at github.com/inconshreveable/go-update, modified for the needs within MinIO project

Package update provides functionality to implement secure, self-updating Go programs (or other single-file targets) A program can update itself by replacing its executable file with a new version.

It provides the flexibility to implement different updating user experiences like auto-updating, or manual user-initiated updates. It also boasts advanced features like binary patching and code signing verification.

Example of updating from a URL:

import (
    "fmt"
    "net/http"

    "github.com/minio/selfupdate"
)

func doUpdate(url string) error {
    resp, err := http.Get(url)
    if err != nil {
        return err
    }
    defer resp.Body.Close()
    err := selfupdate.Apply(resp.Body, update.Options{})
    if err != nil {
        // error handling
    }
    return err
}

Features

  • Cross platform support (Windows too!)
  • Binary patch application
  • Checksum verification
  • Code signing verification
  • Support for updating arbitrary files

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information. Original work was also distributed under the same license.

Owner
High Performance, Kubernetes Native Object Storage
High Performance, Kubernetes Native Object Storage
Similar Resources

Build an interactive CLI application with Go, Cobra and promptui. Video tutorial available on the Div Rhino YouTube channel.

Build an interactive CLI app with Go, Cobra and promptui Text tutorial: https://divrhino.com/articles/build-interactive-cli-app-with-go-cobra-promptui

Dec 8, 2022

dots is CLI tool to build, version and publish config file bundles.

dots-cli dots is CLI tool to build, version and publish config file bundles. TODO (shared): Writing comprehensive documentation Designing landing page

Aug 24, 2022

Dinogo is an CLI framework for build terminal and shell applications in Go.

dinogo Dinogo is an CLI framework for build terminal and shell applications in Go. Features Cross Platform Fast and efficient Keyboard API Enable/Disa

Aug 29, 2022

Lynx is a command line application that build simple golang project

Lynx is a command line application that build simple golang project

Lynx Lynx is a Golang application for easily creating simple Go project Install Just run below commands for install lynx in your system go get -u gith

Oct 1, 2021

Build command for lambda function

Build command for lambda function GOOS=linux GOARCH=amd64 go build -o main main.go logger.go get_csv.go DynamoDBCreateItem.go #Local Development sam l

Nov 15, 2021

Commands to Build and Run dockerized-go-service

Dockerized Go Service Commands to Build and Run dockerized-go-service Syntax: $ docker image build /path/to -t imageName:version -t imageName:revision

Oct 24, 2021

A CLI tool for GCP Cloud Build Triggers

cbtctl A CLI tool for GCP Cloud Build Triggers Usage Run a build trigger with substitutions $ cbtctl run --project GCP Project Name --trigger Trigg

Nov 9, 2021

learn go build --tags and ldflags

Learn tags and ldflags for go build go build -tags debug -ldflags "-X main.version=`autotag current`" -o normal ./normal output is: running version is

Dec 26, 2021

Todos REST API build using echo server.

Todos REST API build using echo server.

Feb 2, 2022
Comments
  • After selfupdate.Apply, how to restart?

    After selfupdate.Apply, how to restart?

    Hi, I call

    	err = selfupdate.Apply(resp.Body, selfupdate.Options{})
    	if err != nil {
    		// error handling
    		fmt.Println(err)
    	} else {
    		fmt.Println("update completed.")
    	}
    

    and the program did not restart. I use follow code, also can not restart.

    "github.com/kardianos/osext"
    func restart() error {
    	name, err := osext.Executable()
    	if err != nil {
    		return err
    	}
    	fmt.Println("name:", name)
    	return exec.Command(name, os.Args[1:]...).Start()
    }
    

    How to restart it? thanks you.

  • remove custom minisign implementation

    remove custom minisign implementation

    This commit removes the custom (partial) minisign implementation and instead relies on github.com/aead/minisign.

    This commit should not cause any behavior or API changes.

  • fix: Recalculate parameters in CommitBinary()

    fix: Recalculate parameters in CommitBinary()

    After splitting Apply into two functions, there was missing recalculation of targetPath in CommitBinary() API.

    Ensure that parameters are recalculated in both functions.

    Also use '.check-perm' instead of .new to protect the downloading binary saved as '.new' against a second use of CheckPermissions()

  • Add two new APIs to split the upgrade process

    Add two new APIs to split the upgrade process

    PrepareAndCheckBinary() downloads the binary to a location different to the final destination, it also applies the patch and does the checksum if configured.

    CommitBinary() will move the staging binary to the final location.

    This is useful when you want to upgrade many machines at the same time but you want to load the new binary only when the download is successful in all of those machines. In that case, CommitBinary() will less likely to fail.

    Apply() will keep its current behavior and will call PrepareAndCheckBinary() and CommitBinary()

mlp is a comman line tool responsible for creating, updating and deleting kubernetes resources based on files generated by Mia-Platform Console.

mlp is a comman line tool responsible for creating, updating and deleting kubernetes resources based on files generated by Mia-Platform Console.

Apr 28, 2022
Small CLI based programs for solving structural engineering design problems based on the book 'Structural Concrete'

Small CLI based programs for solving structural engineering design problems based on the book 'Structural Concrete' written by M. Nadim Hassoun and Akhtem Al-Manaseer (edition-6)

Nov 26, 2021
Inotify-tools is a C library and a set of command-line programs providing a simple interface to inotify.

inotify-tools This is a package of some commandline utilities relating to inotify. The general purpose of this package is to allow inotify's features

Jan 4, 2023
A Go implementation of gnu-coreutils programs

Go-Coreutils A Go implementation of gnu-coreutils programs (https://www.gnu.org/software/coreutils/manual/coreutils.html) Build and Run In the root di

Jan 15, 2022
Tools for the Gio project, most notably gogio for packaging Gio programs

Gio Tools Tools for the Gio project, most notably gogio for packaging Gio programs. Issues File bugs and TODOs through the issue tracker or send an em

Oct 5, 2022
self-aware Golang profile dumper[beta]

holmes WARNING : holmes is under heavy development now, so API will make breaking change during dev. If you want to use it in production, please wait

Jan 6, 2023
code is pretty self explanatory and decently commented
code is pretty self explanatory and decently commented

square_approximation code is pretty self explanatory and decently commented when limit set to 10^9 or more ram usage goes to >42 gigs of ram which is

Apr 7, 2022
Self-host your GitHub repositories.

self-forge One day, I'd like to write a lightweight clone of GitHub. For now, here's ~100 lines of Go that host your source files. Clones all of a Git

Jan 6, 2022
A simple single-file executable to pull a git-ssh repository and serve the web app found to a self-contained browser window

go-git-serve A simple single-file executable to pull a git-ssh repository (using go-git library) and serve the web app found to a self-contained brows

Jan 19, 2022
ops - build and run nanos unikernels
ops - build and run nanos unikernels

OPS Ops is a tool for creating and running a Nanos unikernel. It is used to package, create and run your application as a nanos unikernel instance. Ch

Dec 30, 2022