feat: initial goget release — modern IPv6-first download utility

This commit is contained in:
2026-06-26 21:21:58 +02:00
commit 53db81e1f7
147 changed files with 45931 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
//go:build linux || freebsd
// +build linux freebsd
// Package register provides a single registration point for all built-in goget protocols.
// Both CLI (cmd/goget) and library API (pkg/api) call RegisterAll to avoid
// duplicating the protocol registration list across packages.
package register
import (
"codeberg.org/petrbalvin/goget/internal/core"
"codeberg.org/petrbalvin/goget/internal/protocol"
"codeberg.org/petrbalvin/goget/internal/protocol/dataurl"
"codeberg.org/petrbalvin/goget/internal/protocol/file"
"codeberg.org/petrbalvin/goget/internal/protocol/ftp"
"codeberg.org/petrbalvin/goget/internal/protocol/gemini"
"codeberg.org/petrbalvin/goget/internal/protocol/gopher"
"codeberg.org/petrbalvin/goget/internal/protocol/http"
"codeberg.org/petrbalvin/goget/internal/protocol/sftp"
"codeberg.org/petrbalvin/goget/internal/protocol/webdav"
)
// RegisterAll registers all built-in protocols on the given registry.
// Protocols that are already registered are silently skipped, making this
// safe to call from both CLI and API initialization.
// Returns the HTTP protocol handler for further configuration (e.g., HSTS).
func RegisterAll(r *protocol.Registry) (*http.Client, error) {
registerIfMissing := func(p core.Protocol) {
if r.Supports(p.Scheme()) {
return
}
_ = r.Register(p)
}
httpClient, err := http.NewClient(http.DefaultConfig())
if err != nil {
return nil, err
}
registerIfMissing(httpClient)
registerIfMissing(ftp.NewProtocol())
registerIfMissing(file.NewProtocol())
registerIfMissing(dataurl.NewProtocol())
registerIfMissing(gopher.NewProtocol())
registerIfMissing(gemini.NewProtocol())
registerIfMissing(sftp.NewProtocol())
registerIfMissing(webdav.NewProtocol())
return httpClient, nil
}