A Go library for downloading, comparing, and installing GitHub release assets with a chainable API.
go get -u github.com/Cyberhan123/libfetchpackage main
import (
"fmt"
"github.com/Cyberhan123/libfetch"
)
func main() {
// Create API instance with default settings
api := libfetch.NewApi()
// Set installation directory and other options
api.SetInstallDir("./install")
api.SetRetryCount(5)
api.SetRetryTimeDelay(3) // 3 seconds
api.SetProxy("http://proxy.example.com:8080")
// Download and install the latest release
err := api.Repo("owner/repo").Latest().Install(func(version string) string {
// Return asset name based on version
return fmt.Sprintf("asset-%s.zip", version)
})
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println("Installation completed successfully!")
// Check installed version
versionInfo, err := api.Repo("owner/repo").GetInstalledVersion()
if err != nil {
fmt.Printf("Error getting installed version: %v\n", err)
return
}
fmt.Printf("Installed version: %s\n", versionInfo.TagName)
}HTTP_PROXY- HTTP proxy URLHTTPS_PROXY- HTTPS proxy URL (used if HTTP_PROXY is not set)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Clone your fork
- Create a feature branch
- Make changes
- Run tests
- Submit a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please open an issue on GitHub.
Made with ❤️ in Go