mirror of
https://github.com/laravel-ls/uri
synced 2026-07-04 08:23:43 +02:00
module: remove x/xerrors dependency
This commit is contained in:
parent
016c8743e5
commit
63eaac75cc
2 changed files with 6 additions and 10 deletions
5
go.mod
5
go.mod
|
|
@ -2,7 +2,4 @@ module go.lsp.dev/uri
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require github.com/google/go-cmp v0.4.0
|
||||||
github.com/google/go-cmp v0.4.0
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
|
|
||||||
)
|
|
||||||
|
|
|
||||||
11
uri.go
11
uri.go
|
|
@ -5,14 +5,13 @@
|
||||||
package uri
|
package uri
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -59,11 +58,11 @@ func (u URI) Filename() string {
|
||||||
func filename(uri URI) (string, error) {
|
func filename(uri URI) (string, error) {
|
||||||
u, err := url.ParseRequestURI(string(uri))
|
u, err := url.ParseRequestURI(string(uri))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", xerrors.Errorf("failed to parse request URI: %w", err)
|
return "", fmt.Errorf("failed to parse request URI: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.Scheme != FileScheme {
|
if u.Scheme != FileScheme {
|
||||||
return "", xerrors.Errorf("only file URIs are supported, got %v", u.Scheme)
|
return "", fmt.Errorf("only file URIs are supported, got %v", u.Scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isWindowsDriveURI(u.Path) {
|
if isWindowsDriveURI(u.Path) {
|
||||||
|
|
@ -116,7 +115,7 @@ func File(path string) URI {
|
||||||
func Parse(s string) (u URI, err error) {
|
func Parse(s string) (u URI, err error) {
|
||||||
us, err := url.Parse(s)
|
us, err := url.Parse(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return u, xerrors.Errorf("url.Parse: %w\n", err)
|
return u, fmt.Errorf("url.Parse: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch us.Scheme {
|
switch us.Scheme {
|
||||||
|
|
@ -139,7 +138,7 @@ func Parse(s string) (u URI, err error) {
|
||||||
u = URI(ut.String())
|
u = URI(ut.String())
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return u, xerrors.New("unknown scheme")
|
return u, errors.New("unknown scheme")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue