internal/lsp/source: Use file:///C:/ on Windows file system

URI should be started with file:/// always.

Change-Id: I123e577d421de3e85dfec00596fbdb63c2231938
Reviewed-on: https://go-review.googlesource.com/c/153618
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Yasuhiro Matsumoto 2018-12-12 01:02:12 +09:00 committed by Rebecca Stambler
parent b620e9ecbe
commit 49db546f37
4 changed files with 44 additions and 2 deletions

View File

@ -12,8 +12,6 @@ import (
"strings" "strings"
) )
const fileSchemePrefix = "file://"
// URI represents the full uri for a file. // URI represents the full uri for a file.
type URI string type URI string

View File

@ -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://"

View File

@ -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:///"

View File

@ -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)
}
}