Vendor dependencies and expose control program binaries via nix build. Uses nixpkgs-unstable for Go 1.26 support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
423 B
Go
26 lines
423 B
Go
package url
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
var errNoScheme = errors.New("no scheme")
|
|
var errEmptyURL = errors.New("URL cannot be empty")
|
|
|
|
// schemeFromURL returns the scheme from a URL string
|
|
func SchemeFromURL(url string) (string, error) {
|
|
if url == "" {
|
|
return "", errEmptyURL
|
|
}
|
|
|
|
i := strings.Index(url, ":")
|
|
|
|
// No : or : is the first character.
|
|
if i < 1 {
|
|
return "", errNoScheme
|
|
}
|
|
|
|
return url[0:i], nil
|
|
}
|