git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/selfupdate/channel.go (about)

     1  package selfupdate
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  )
     7  
     8  type ChannelManifest struct {
     9  	Name    string `json:"name"`
    10  	Channel string `json:"channel"`
    11  	Version string `json:"version"`
    12  }
    13  
    14  func (manifest ChannelManifest) ToJson() (manifestJSON []byte, err error) {
    15  	manifestJSON, err = json.MarshalIndent(manifest, "", "  ")
    16  	if err != nil {
    17  		err = fmt.Errorf("selfupdate: encoding manifest to JSON: %w", err)
    18  		return
    19  	}
    20  
    21  	return
    22  }