Documentation ¶
Overview ¶
Package output holds the supported sources.
Example (Local) ¶
package main import ( "fmt" "os" "path/filepath" "reflect" "github.com/victorpopkov/go-appcast/source" ) func testdataPath(paths ...string) string { testdataPath := "./testdata/" pwd, err := os.Getwd() if err != nil { fmt.Println(err.Error()) os.Exit(1) } return filepath.Join(pwd, testdataPath, filepath.Join(paths...)) } func main() { src := source.NewLocal(testdataPath("example.xml")) err := src.Load() if err != nil { panic(err) } fmt.Println("Type:", reflect.TypeOf(src)) fmt.Println("Content:", fmt.Sprintf("%d (%s)", len(src.Content()), "length")) fmt.Println("Checksum:", fmt.Sprintf("%s (%s)", src.Checksum().String(), src.Checksum().Algorithm())) }
Output: Type: *source.Local Content: 2048 (length) Checksum: 0cb017e2dfd65e07b54580ca8d4eedbfcf6cef5824bcd9539a64afb72fa9ce8c (SHA256)
Example (Remote) ¶
// mock the request content := testdata("example.xml") httpmock.ActivateNonDefault(source.DefaultClient.HTTPClient) httpmock.RegisterResponder("GET", "https://www.adium.im/sparkle/appcast-release.xml", httpmock.NewBytesResponder(200, content)) defer httpmock.DeactivateAndReset() // example src, err := source.NewRemote("https://www.adium.im/sparkle/appcast-release.xml") if err != nil { panic(err) } err = src.Load() if err != nil { panic(err) } fmt.Println("Type:", reflect.TypeOf(src)) fmt.Println("Content:", fmt.Sprintf("%d (%s)", len(src.Content()), "length")) fmt.Println("Checksum:", fmt.Sprintf("%s (%s)", src.Checksum().String(), src.Checksum().Algorithm()))
Output: Type: *source.Remote Content: 2048 (length) Checksum: 0cb017e2dfd65e07b54580ca8d4eedbfcf6cef5824bcd9539a64afb72fa9ce8c (SHA256)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = client.New()
DefaultClient is the default Client that is used for making requests in the appcast package.
var LocalReadFile = ioutil.ReadFile
Functions ¶
This section is empty.
Types ¶
type Local ¶
Local represents an appcast source from the local file.
func (*Local) Load ¶
Load loads an appcast content into the Local.Source.content from the local file by using the path specified in Local.filepath set earlier.
func (*Local) SetFilepath ¶
SetFilepath is a Local.filepath setter.
type Remote ¶
Remote represents an appcast source from the remote location.
func NewRemote ¶
NewRemote returns a new Remote instance pointer with the prepared Remote.request and Remote.url ready to be used Remote.load.
Supports both the remote URL string or Request struct pointer as an argument.
func (*Remote) Load ¶
Load loads an appcast content into the Remote.Source.content from the remote source by using the Remote.request set earlier.
func (*Remote) SetRequest ¶
SetRequest is a Remote.request setter.