diff --git a/internal/lsp/source/uri.go b/internal/lsp/source/uri.go index 59429292..4e6d58e6 100644 --- a/internal/lsp/source/uri.go +++ b/internal/lsp/source/uri.go @@ -12,8 +12,6 @@ import ( "strings" ) -const fileSchemePrefix = "file://" - // URI represents the full uri for a file. type URI string diff --git a/internal/lsp/source/uri_unix.go b/internal/lsp/source/uri_unix.go new file mode 100644 index 00000000..de7dc3ac --- /dev/null +++ b/internal/lsp/source/uri_unix.go @@ -0,0 +1,9 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !windows + +package source + +const fileSchemePrefix = "file://" diff --git a/internal/lsp/source/uri_windows.go b/internal/lsp/source/uri_windows.go new file mode 100644 index 00000000..00cfce86 --- /dev/null +++ b/internal/lsp/source/uri_windows.go @@ -0,0 +1,9 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package source + +const fileSchemePrefix = "file:///" diff --git a/internal/lsp/source/uri_windows_test.go b/internal/lsp/source/uri_windows_test.go new file mode 100644 index 00000000..aa9025f1 --- /dev/null +++ b/internal/lsp/source/uri_windows_test.go @@ -0,0 +1,26 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package source + +import ( + "testing" +) + +func TestURIWindows(t *testing.T) { + s := `C:\Windows\System32` + uri := ToURI(s) + if uri != `file:///C:/Windows/System32` { + t.Fatalf("ToURI: got %v want %v", uri, s) + } + f, err := URI(uri).Filename() + if err != nil { + t.Fatal(err) + } + if f != s { + t.Fatalf("Filename: got %v want %v", f, s) + } +}